Skip to content

Commit

Permalink
🤖 Add worker automation
Browse files Browse the repository at this point in the history
  • Loading branch information
KimlikDAO-bot committed Aug 26, 2024
1 parent 81acfcc commit 3d30e60
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 34 deletions.
2 changes: 2 additions & 0 deletions api/oauth2.d.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ oauth2.AccessToken;
* }}
*/
oauth2.AccessTokenRequest;

export default oauth2;
56 changes: 53 additions & 3 deletions birimler/cloudflare/targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @typedef {{
* accountId: string,
* authToken: string
* token: string
* }}
*/
const Auth = {};
Expand All @@ -12,7 +12,57 @@ const Auth = {};
* @param {string} name
* @param {string} url
* @param {string} code
* @param {!Array<{
* name: string,
* namespace_id: string
* }>=} kvBindings
*/
const uploadWoker = (auth, name, url, code) => {
const uploadWorker = (auth, name, code, kvBindings) => {
/** @const {string} */
const yesterday = new Date(Date.now() - 86400000)
.toISOString().split('T')[0];
/** @dict */
const metadata = {
"main_module": "a.js",
"compatibility_date": yesterday
};
if (kvBindings && kvBindings.length) {
for (const kv of kvBindings)
kv["type"] = "kv_namespace";
metadata["bindings"] = kvBindings;
}
/** @const {!FormData} */
const form = new FormData();
form.append("metadata", new Blob([JSON.stringify(metadata)], { type: "application/json" }));
form.append("a.js", new File([code], "a.js", { type: "application/javascript+module;charset=utf-8" }));
return fetch(`https://api.cloudflare.com/client/v4/accounts/${auth.accountId}/workers/scripts/${name}`, {
method: "PUT",
headers: { "authorization": `Bearer ${auth.token}` },
body: form
}).then((res) => res.json());
};

}
/**
* @param {Auth} auth
* @param {string} name
* @param {string} url
*/
const bindWorker = (auth, name, url) => fetch(
`https://api.cloudflare.com/client/v4/accounts/${auth.accountId}/workers/domains`, {
method: "PUT",
headers: {
"authorization": `Bearer ${auth.token}`,
"content-type": "application/json"
},
body: JSON.stringify({
"environment": "production",
"hostname": url,
"service": name
})
}).then((res) => res.json());

export {
Auth,
bindWorker,
uploadWorker
};
4 changes: 0 additions & 4 deletions birimler/js/build.js

This file was deleted.

2 changes: 1 addition & 1 deletion birimler/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import toml from "toml";
/**
* @param {string} definesFile
* @param {string} module
* @return {!Array<string>}
* @return {!Promise<!Array<string>>}
*/
const readDefines = (definesFile, module) => readFile(definesFile)
.then(
Expand Down
13 changes: 0 additions & 13 deletions birimler/js/worker.js

This file was deleted.

9 changes: 8 additions & 1 deletion crosschain/chains.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ const ChainGroup = {
*/
const ChainGroups = [ChainGroup.EVM, ChainGroup.MINA];

/**
* @param {ChainId} id
* @return {ChainGroup}
*/
const chainIdToGroup = (id) => /** @type {ChainGroup} */(id.slice(2));

export {
ChainGroup,
ChainGroups,
ChainId
ChainId,
chainIdToGroup
};
2 changes: 1 addition & 1 deletion crypto/modular.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const expTimesExp = (a, x, b, y, M) => {
*/
const tonelliShanks = (n, P, Q, c, M) => {
if (n == 0n) return 0n;
/**@type {bigint} */
/** @type {bigint} */
let t = exp(n, (Q - 1n) >> 1n, P);
/** @type {bigint} */
let R = t * n % P;
Expand Down
2 changes: 1 addition & 1 deletion kdjs/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Params = {};
const compile = async (params, checkFreshFn) => {
/** @const {string} */
const isolateDir = combine(
getDir(/** @type {string} */(params["output"] || /** @type {string} */(params["entry"]))),
getDir(/** @type {string} */(params["output"] || "build/" + /** @type {string} */(params["entry"]))),
/** @type {string} */(params["isolateDir"]) || ".kdjs_isolate");
const {
/** @const {!Map<string, ImportStatement>} */ missingImports,
Expand Down
10 changes: 4 additions & 6 deletions node/ipfs.d.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import node from "./node.d";
node.ipfs = {};

/**
* @constructor
* @struct
* @typedef {{
* Hash: string
* }}
*/
node.ipfs.AddResult = function () { }

/** @type {string} */
node.ipfs.AddResult.prototype.Hash;
node.ipfs.AddResult;
2 changes: 1 addition & 1 deletion node/ipfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const yaz = (nodeUrl, veri, veriÅžekli) => {
body: formData
})
.then((res) => res.json())
.then((/** @type {!node.ipfs.AddResult} */ res) => res.Hash)
.then((/** @type {node.ipfs.AddResult} */ res) => res.Hash)

return Promise.all([hash(encoded), gelenSöz])
.then(([/** !Uint8Array */ yerel, /** string */ gelen]) => CID(yerel) == gelen
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
},
"devDependencies": {
"@ethereumjs/evm": "^3.1.0",
"@noble/secp256k1": "^2.0.0",
"@noble/secp256k1": "^2.1.0",
"ethers": "^6.13.2",
"mina-signer": "^3.0.7"
},
"dependencies": {
"acorn": "^8.12.1",
"acorn-walk": "^8.3.3",
"astring": "^1.8.6",
"astring": "^1.9.0",
"google-closure-compiler": "^20240317.0.0",
"htmlparser2": "^9.1.0",
"uglify-js": "^3.19.1"
"uglify-js": "^3.19.2"
}
}

0 comments on commit 3d30e60

Please sign in to comment.