@layerzerolabs/gated-transaction 0.0.23 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +43 -35
- package/.turbo/turbo-checkdeps.log +2 -2
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +3 -3
- package/dist/DBJG544E.js +55 -0
- package/dist/DBJG544E.js.map +1 -0
- package/dist/QGZD4SJ4.cjs +59 -0
- package/dist/QGZD4SJ4.cjs.map +1 -0
- package/dist/gatedTransactionSignalLock.cjs +22 -0
- package/dist/gatedTransactionSignalLock.cjs.map +1 -0
- package/dist/gatedTransactionSignalLock.d.ts +14 -0
- package/dist/gatedTransactionSignalLock.d.ts.map +1 -0
- package/dist/gatedTransactionSignalLock.js +5 -0
- package/dist/gatedTransactionSignalLock.js.map +1 -0
- package/dist/index.cjs +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +10 -12
- package/src/gatedTransactionSignalLock.ts +82 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +1 -9
- package/.turbo/turbo-checkcatalog.log +0 -8
package/.turbo/turbo-build.log
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
> @layerzerolabs/gated-transaction@0.0.0 build /home/runner/work/monorepo-internal/monorepo-internal/packages/gated-transaction
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
|
-
[34mCLI[39m Building entry: src/gatedTx.ts, src/index.ts, src/resolver.ts, src/types.ts
|
|
5
|
+
[34mCLI[39m Building entry: src/gatedTransactionSignalLock.ts, src/gatedTx.ts, src/index.ts, src/resolver.ts, src/types.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.4.0
|
|
8
8
|
[34mCLI[39m Using tsup config: /home/runner/work/monorepo-internal/monorepo-internal/packages/gated-transaction/tsup.config.ts
|
|
@@ -10,37 +10,45 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mCJS[39m Build start
|
|
12
12
|
[34mESM[39m Build start
|
|
13
|
-
[32mCJS[39m [1mdist/gatedTx.cjs
|
|
14
|
-
[32mCJS[39m [1mdist/
|
|
15
|
-
[32mCJS[39m [1mdist/
|
|
16
|
-
[32mCJS[39m [1mdist/
|
|
17
|
-
[32mCJS[39m [1mdist/
|
|
18
|
-
[32mCJS[39m [1mdist/types.cjs
|
|
19
|
-
[32mCJS[39m [1mdist/
|
|
20
|
-
[32mCJS[39m [1mdist/
|
|
21
|
-
[32mCJS[39m [1mdist/
|
|
22
|
-
[32mCJS[39m [1mdist/
|
|
23
|
-
[32mCJS[39m [1mdist/
|
|
24
|
-
[32mCJS[39m [1mdist/
|
|
25
|
-
[32mCJS[39m [1mdist/
|
|
26
|
-
[32mCJS[39m [1mdist/types.cjs.map
|
|
27
|
-
[32mCJS[39m [1mdist/
|
|
28
|
-
[32mCJS[39m [1mdist/index.cjs.map
|
|
29
|
-
[32mCJS[39m
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[32mESM[39m [1mdist/
|
|
35
|
-
[32mESM[39m [1mdist/
|
|
36
|
-
[32mESM[39m [1mdist/
|
|
37
|
-
[32mESM[39m [1mdist/
|
|
38
|
-
[32mESM[39m [1mdist/
|
|
39
|
-
[32mESM[39m [1mdist/
|
|
40
|
-
[32mESM[39m [1mdist/
|
|
41
|
-
[32mESM[39m [1mdist/
|
|
42
|
-
[32mESM[39m [1mdist/
|
|
43
|
-
[32mESM[39m [1mdist/GLQGPA3F.js
|
|
44
|
-
[32mESM[39m [1mdist/
|
|
45
|
-
[32mESM[39m [1mdist/
|
|
46
|
-
[32mESM[39m
|
|
13
|
+
[32mCJS[39m [1mdist/gatedTx.cjs [22m[32m474.00 B[39m
|
|
14
|
+
[32mCJS[39m [1mdist/gatedTransactionSignalLock.cjs [22m[32m697.00 B[39m
|
|
15
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m2.14 KB[39m
|
|
16
|
+
[32mCJS[39m [1mdist/resolver.cjs [22m[32m546.00 B[39m
|
|
17
|
+
[32mCJS[39m [1mdist/QGZD4SJ4.cjs [22m[32m2.36 KB[39m
|
|
18
|
+
[32mCJS[39m [1mdist/types.cjs [22m[32m950.00 B[39m
|
|
19
|
+
[32mCJS[39m [1mdist/AYIRG6WY.cjs [22m[32m725.00 B[39m
|
|
20
|
+
[32mCJS[39m [1mdist/KX7INHSQ.cjs [22m[32m6.99 KB[39m
|
|
21
|
+
[32mCJS[39m [1mdist/BSVO6MXQ.cjs [22m[32m3.31 KB[39m
|
|
22
|
+
[32mCJS[39m [1mdist/YJF4D23A.cjs [22m[32m245.00 B[39m
|
|
23
|
+
[32mCJS[39m [1mdist/gatedTx.cjs.map [22m[32m72.00 B[39m
|
|
24
|
+
[32mCJS[39m [1mdist/gatedTransactionSignalLock.cjs.map [22m[32m91.00 B[39m
|
|
25
|
+
[32mCJS[39m [1mdist/resolver.cjs.map [22m[32m73.00 B[39m
|
|
26
|
+
[32mCJS[39m [1mdist/types.cjs.map [22m[32m70.00 B[39m
|
|
27
|
+
[32mCJS[39m [1mdist/AYIRG6WY.cjs.map [22m[32m1.98 KB[39m
|
|
28
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m70.00 B[39m
|
|
29
|
+
[32mCJS[39m [1mdist/QGZD4SJ4.cjs.map [22m[32m5.54 KB[39m
|
|
30
|
+
[32mCJS[39m [1mdist/KX7INHSQ.cjs.map [22m[32m17.93 KB[39m
|
|
31
|
+
[32mCJS[39m [1mdist/BSVO6MXQ.cjs.map [22m[32m9.55 KB[39m
|
|
32
|
+
[32mCJS[39m [1mdist/YJF4D23A.cjs.map [22m[32m73.00 B[39m
|
|
33
|
+
[32mCJS[39m ⚡️ Build success in 172ms
|
|
34
|
+
[32mESM[39m [1mdist/gatedTransactionSignalLock.js [22m[32m270.00 B[39m
|
|
35
|
+
[32mESM[39m [1mdist/gatedTx.js [22m[32m180.00 B[39m
|
|
36
|
+
[32mESM[39m [1mdist/index.js [22m[32m554.00 B[39m
|
|
37
|
+
[32mESM[39m [1mdist/DBJG544E.js [22m[32m2.17 KB[39m
|
|
38
|
+
[32mESM[39m [1mdist/resolver.js [22m[32m238.00 B[39m
|
|
39
|
+
[32mESM[39m [1mdist/5INFRBMB.js [22m[32m616.00 B[39m
|
|
40
|
+
[32mESM[39m [1mdist/types.js [22m[32m263.00 B[39m
|
|
41
|
+
[32mESM[39m [1mdist/742WLBNW.js [22m[32m6.50 KB[39m
|
|
42
|
+
[32mESM[39m [1mdist/VUOMXK5T.js [22m[32m222.00 B[39m
|
|
43
|
+
[32mESM[39m [1mdist/GLQGPA3F.js [22m[32m2.39 KB[39m
|
|
44
|
+
[32mESM[39m [1mdist/gatedTransactionSignalLock.js.map [22m[32m90.00 B[39m
|
|
45
|
+
[32mESM[39m [1mdist/gatedTx.js.map [22m[32m71.00 B[39m
|
|
46
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m69.00 B[39m
|
|
47
|
+
[32mESM[39m [1mdist/5INFRBMB.js.map [22m[32m1.97 KB[39m
|
|
48
|
+
[32mESM[39m [1mdist/DBJG544E.js.map [22m[32m5.52 KB[39m
|
|
49
|
+
[32mESM[39m [1mdist/types.js.map [22m[32m69.00 B[39m
|
|
50
|
+
[32mESM[39m [1mdist/resolver.js.map [22m[32m72.00 B[39m
|
|
51
|
+
[32mESM[39m [1mdist/742WLBNW.js.map [22m[32m17.90 KB[39m
|
|
52
|
+
[32mESM[39m [1mdist/VUOMXK5T.js.map [22m[32m72.00 B[39m
|
|
53
|
+
[32mESM[39m [1mdist/GLQGPA3F.js.map [22m[32m9.49 KB[39m
|
|
54
|
+
[32mESM[39m ⚡️ Build success in 173ms
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
> @layerzerolabs/gated-transaction@0.0.0 checkdeps /home/runner/work/monorepo-internal/monorepo-internal/packages/gated-transaction
|
|
3
|
-
> pnpm --filter @layerzerolabs/depcheck run depcheck validate --missing-dependencies --only $npm_package_name
|
|
3
|
+
> pnpm --filter @layerzerolabs/depcheck run depcheck validate --catalog --missing-dependencies --only $npm_package_name
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
> @layerzerolabs/depcheck@1.0.1 depcheck /home/runner/work/monorepo-internal/monorepo-internal/tools/repo/depcheck
|
|
7
|
-
> tsx ./src/index.ts "validate" "--missing-dependencies" "--only" "@layerzerolabs/gated-transaction"
|
|
7
|
+
> tsx ./src/index.ts "validate" "--catalog" "--missing-dependencies" "--only" "@layerzerolabs/gated-transaction"
|
|
8
8
|
|
package/.turbo/turbo-lint.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
[1m[46m RUN [49m[22m [36mv3.2.3 [39m[90m/home/runner/work/monorepo-internal/monorepo-internal/packages/gated-transaction[39m
|
|
7
7
|
|
|
8
|
-
[32m✓[39m test/resolver.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m
|
|
8
|
+
[32m✓[39m test/resolver.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m 318[2mms[22m[39m
|
|
9
9
|
|
|
10
10
|
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
11
11
|
[2m Tests [22m [1m[32m7 passed[39m[22m[90m (7)[39m
|
|
12
|
-
[2m Start at [22m 18:
|
|
13
|
-
[2m Duration [22m
|
|
12
|
+
[2m Start at [22m 18:41:24
|
|
13
|
+
[2m Duration [22m 764ms[2m (transform 75ms, setup 0ms, collect 127ms, tests 318ms, environment 0ms, prepare 121ms)[22m
|
|
14
14
|
|
package/dist/DBJG544E.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getIdForGatedTransaction } from './5INFRBMB.js';
|
|
2
|
+
import { __name } from './VUOMXK5T.js';
|
|
3
|
+
import { defineSignal, defineQuery } from '@layerzerolabs/common-workflow';
|
|
4
|
+
|
|
5
|
+
var gatedTransactionGoSignal = defineSignal("GatedTransactionGo");
|
|
6
|
+
var queryGatedTransactions = defineQuery("GatedTransactionQuery");
|
|
7
|
+
var useGatedTransactionSignalLock = /* @__PURE__ */ __name((fn, getPassthrough) => {
|
|
8
|
+
const approvedIds = /* @__PURE__ */ new Set();
|
|
9
|
+
const approvedBundleNames = /* @__PURE__ */ new Set();
|
|
10
|
+
const pendingTransactions = {};
|
|
11
|
+
const sentTransactions = {};
|
|
12
|
+
const completedTransactions = {};
|
|
13
|
+
fn.setHandler(queryGatedTransactions, () => {
|
|
14
|
+
const passthroughWfIds = getPassthrough?.().map?.((handle) => handle.workflowId);
|
|
15
|
+
return {
|
|
16
|
+
pendingTransactions: Object.values(pendingTransactions),
|
|
17
|
+
sentTransactions: Object.values(sentTransactions),
|
|
18
|
+
completedTransactions: Object.values(completedTransactions),
|
|
19
|
+
passthroughWorkflowIds: passthroughWfIds ?? []
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
fn.setHandler(gatedTransactionGoSignal, async (id) => {
|
|
23
|
+
approvedIds.add(id);
|
|
24
|
+
const passthrough = getPassthrough?.();
|
|
25
|
+
if (passthrough) {
|
|
26
|
+
await Promise.allSettled(passthrough.map((wf) => {
|
|
27
|
+
return wf.signal(gatedTransactionGoSignal, [
|
|
28
|
+
id
|
|
29
|
+
]);
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const confirmationCallback = /* @__PURE__ */ __name(async (tx) => {
|
|
34
|
+
const id = getIdForGatedTransaction(tx);
|
|
35
|
+
pendingTransactions[id] = tx;
|
|
36
|
+
await fn.condition(() => approvedIds.has(id) || !!tx.bundleName && approvedBundleNames.has(tx.bundleName));
|
|
37
|
+
tx.bundleName && approvedBundleNames.add(tx.bundleName);
|
|
38
|
+
sentTransactions[id] = tx;
|
|
39
|
+
delete pendingTransactions[id];
|
|
40
|
+
return true;
|
|
41
|
+
}, "confirmationCallback");
|
|
42
|
+
const onResultCallback = /* @__PURE__ */ __name((result) => {
|
|
43
|
+
const id = getIdForGatedTransaction(result);
|
|
44
|
+
completedTransactions[id] = result;
|
|
45
|
+
delete sentTransactions[id];
|
|
46
|
+
}, "onResultCallback");
|
|
47
|
+
return {
|
|
48
|
+
confirmationCallback,
|
|
49
|
+
onResultCallback
|
|
50
|
+
};
|
|
51
|
+
}, "useGatedTransactionSignalLock");
|
|
52
|
+
|
|
53
|
+
export { gatedTransactionGoSignal, queryGatedTransactions, useGatedTransactionSignalLock };
|
|
54
|
+
//# sourceMappingURL=DBJG544E.js.map
|
|
55
|
+
//# sourceMappingURL=DBJG544E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/gatedTransactionSignalLock.ts"],"names":["gatedTransactionGoSignal","defineSignal","queryGatedTransactions","defineQuery","useGatedTransactionSignalLock","fn","getPassthrough","approvedIds","Set","approvedBundleNames","pendingTransactions","sentTransactions","completedTransactions","setHandler","passthroughWfIds","map","handle","workflowId","Object","values","passthroughWorkflowIds","id","add","passthrough","Promise","allSettled","wf","signal","confirmationCallback","tx","getIdForGatedTransaction","condition","has","bundleName","onResultCallback","result"],"mappings":";;;;AAkBO,IAAMA,wBAAAA,GACTC,aAAuC,oBAAA;AACpC,IAAMC,sBAAAA,GACTC,YAA0C,uBAAA;AAEvC,IAAMC,6BAAAA,mBAAgC,MAAA,CAAA,CACzCC,EAAAA,EACAC,cAAAA,KAAAA;AAEA,EAAA,MAAMC,WAAAA,uBAA2CC,GAAAA,EAAAA;AACjD,EAAA,MAAMC,mBAAAA,uBAAuCD,GAAAA,EAAAA;AAE7C,EAAA,MAAME,sBAAoE,EAAC;AAC3E,EAAA,MAAMC,mBAAiE,EAAC;AACxE,EAAA,MAAMC,wBAGF,EAAC;AAELP,EAAAA,EAAAA,CAAGQ,UAAAA,CAAWX,wBAAwB,MAAA;AAClC,IAAA,MAAMY,mBAAmBR,cAAAA,IAAAA,CAAmBS,MAAM,CAACC,MAAAA,KAAWA,OAAOC,UAAU,CAAA;AAC/E,IAAA,OAAO;MACHP,mBAAAA,EAAqBQ,MAAAA,CAAOC,OAAOT,mBAAAA,CAAAA;MACnCC,gBAAAA,EAAkBO,MAAAA,CAAOC,OAAOR,gBAAAA,CAAAA;MAChCC,qBAAAA,EAAuBM,MAAAA,CAAOC,OAAOP,qBAAAA,CAAAA;AACrCQ,MAAAA,sBAAAA,EAAwBN,oBAAoB;AAChD,KAAA;EACJ,CAAA,CAAA;AAEAT,EAAAA,EAAAA,CAAGQ,UAAAA,CAAWb,wBAAAA,EAA0B,OAAOqB,EAAAA,KAAAA;AAC3Cd,IAAAA,WAAAA,CAAYe,IAAID,EAAAA,CAAAA;AAChB,IAAA,MAAME,cAAcjB,cAAAA,IAAAA;AACpB,IAAA,IAAIiB,WAAAA,EAAa;AACb,MAAA,MAAMC,OAAAA,CAAQC,UAAAA,CACVF,WAAAA,CAAYR,GAAAA,CAAI,CAACW,EAAAA,KAAAA;AACb,QAAA,OAAOA,EAAAA,CAAGC,OAAO3B,wBAAAA,EAA0B;AAACqB,UAAAA;AAAG,SAAA,CAAA;AACnD,MAAA,CAAA,CAAA,CAAA;AAER,IAAA;EACJ,CAAA,CAAA;AAEA,EAAA,MAAMO,oBAAAA,iCAAgFC,EAAAA,KAAAA;AAClF,IAAA,MAAMR,EAAAA,GAAKS,yBAAyBD,EAAAA,CAAAA;AACpCnB,IAAAA,mBAAAA,CAAoBW,EAAAA,CAAAA,GAAMQ,EAAAA;AAE1B,IAAA,MAAMxB,EAAAA,CAAG0B,SAAAA,CACL,MACIxB,WAAAA,CAAYyB,IAAIX,EAAAA,CAAAA,IAAQ,CAAC,CAACQ,GAAGI,UAAAA,IAAcxB,mBAAAA,CAAoBuB,GAAAA,CAAIH,EAAAA,CAAGI,UAAU,CAAA,CAAA;AAGxFJ,IAAAA,EAAAA,CAAGI,UAAAA,IAAcxB,mBAAAA,CAAoBa,GAAAA,CAAIO,EAAAA,CAAGI,UAAU,CAAA;AACtDtB,IAAAA,gBAAAA,CAAiBU,EAAAA,CAAAA,GAAMQ,EAAAA;AACvB,IAAA,OAAOnB,oBAAoBW,EAAAA,CAAAA;AAC3B,IAAA,OAAO,IAAA;EACX,CAAA,EAb+E,sBAAA,CAAA;AAe/E,EAAA,MAAMa,gBAAAA,2BAAkEC,MAAAA,KAAAA;AACpE,IAAA,MAAMd,EAAAA,GAAKS,yBAAyBK,MAAAA,CAAAA;AACpCvB,IAAAA,qBAAAA,CAAsBS,EAAAA,CAAAA,GAAMc,MAAAA;AAC5B,IAAA,OAAOxB,iBAAiBU,EAAAA,CAAAA;EAC5B,CAAA,EAJuE,kBAAA,CAAA;AAMvE,EAAA,OAAO;AAAEO,IAAAA,oBAAAA;AAAsBM,IAAAA;AAAiB,GAAA;AACpD,CAAA,EA1D6C,+BAAA","file":"DBJG544E.js","sourcesContent":["import type { WorkflowFunctions, WorkflowHandle } from '@layerzerolabs/common-workflow';\nimport { defineQuery, defineSignal } from '@layerzerolabs/common-workflow';\n\nimport { getIdForGatedTransaction } from './gatedTx';\nimport type {\n GatedTransaction,\n GatedTransactionId,\n GatedTransactionResult,\n UserInteractionCallbacks,\n} from './types';\n\nexport type QueryGatedTransactionsResult = {\n pendingTransactions: GatedTransaction[];\n sentTransactions: GatedTransaction[];\n completedTransactions: (GatedTransaction & { result: GatedTransactionResult })[];\n passthroughWorkflowIds: string[];\n};\n\nexport const gatedTransactionGoSignal =\n defineSignal<[id: GatedTransactionId]>('GatedTransactionGo');\nexport const queryGatedTransactions =\n defineQuery<QueryGatedTransactionsResult>('GatedTransactionQuery');\n\nexport const useGatedTransactionSignalLock = (\n fn: WorkflowFunctions,\n getPassthrough?: () => WorkflowHandle<any>[],\n): UserInteractionCallbacks => {\n const approvedIds: Set<GatedTransactionId> = new Set();\n const approvedBundleNames: Set<string> = new Set();\n\n const pendingTransactions: Record<GatedTransactionId, GatedTransaction> = {};\n const sentTransactions: Record<GatedTransactionId, GatedTransaction> = {};\n const completedTransactions: Record<\n GatedTransactionId,\n GatedTransaction & { result: GatedTransactionResult }\n > = {};\n\n fn.setHandler(queryGatedTransactions, () => {\n const passthroughWfIds = getPassthrough?.().map?.((handle) => handle.workflowId);\n return {\n pendingTransactions: Object.values(pendingTransactions),\n sentTransactions: Object.values(sentTransactions),\n completedTransactions: Object.values(completedTransactions),\n passthroughWorkflowIds: passthroughWfIds ?? [],\n };\n });\n\n fn.setHandler(gatedTransactionGoSignal, async (id) => {\n approvedIds.add(id);\n const passthrough = getPassthrough?.();\n if (passthrough) {\n await Promise.allSettled(\n passthrough.map((wf) => {\n return wf.signal(gatedTransactionGoSignal, [id]);\n }),\n );\n }\n });\n\n const confirmationCallback: UserInteractionCallbacks['confirmationCallback'] = async (tx) => {\n const id = getIdForGatedTransaction(tx);\n pendingTransactions[id] = tx;\n\n await fn.condition(\n () =>\n approvedIds.has(id) || (!!tx.bundleName && approvedBundleNames.has(tx.bundleName)),\n );\n\n tx.bundleName && approvedBundleNames.add(tx.bundleName);\n sentTransactions[id] = tx;\n delete pendingTransactions[id];\n return true;\n };\n\n const onResultCallback: UserInteractionCallbacks['onResultCallback'] = (result) => {\n const id = getIdForGatedTransaction(result);\n completedTransactions[id] = result;\n delete sentTransactions[id];\n };\n\n return { confirmationCallback, onResultCallback };\n};\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var AYIRG6WY_cjs = require('./AYIRG6WY.cjs');
|
|
4
|
+
var YJF4D23A_cjs = require('./YJF4D23A.cjs');
|
|
5
|
+
var commonWorkflow = require('@layerzerolabs/common-workflow');
|
|
6
|
+
|
|
7
|
+
var gatedTransactionGoSignal = commonWorkflow.defineSignal("GatedTransactionGo");
|
|
8
|
+
var queryGatedTransactions = commonWorkflow.defineQuery("GatedTransactionQuery");
|
|
9
|
+
var useGatedTransactionSignalLock = /* @__PURE__ */ YJF4D23A_cjs.__name((fn, getPassthrough) => {
|
|
10
|
+
const approvedIds = /* @__PURE__ */ new Set();
|
|
11
|
+
const approvedBundleNames = /* @__PURE__ */ new Set();
|
|
12
|
+
const pendingTransactions = {};
|
|
13
|
+
const sentTransactions = {};
|
|
14
|
+
const completedTransactions = {};
|
|
15
|
+
fn.setHandler(queryGatedTransactions, () => {
|
|
16
|
+
const passthroughWfIds = getPassthrough?.().map?.((handle) => handle.workflowId);
|
|
17
|
+
return {
|
|
18
|
+
pendingTransactions: Object.values(pendingTransactions),
|
|
19
|
+
sentTransactions: Object.values(sentTransactions),
|
|
20
|
+
completedTransactions: Object.values(completedTransactions),
|
|
21
|
+
passthroughWorkflowIds: passthroughWfIds ?? []
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
fn.setHandler(gatedTransactionGoSignal, async (id) => {
|
|
25
|
+
approvedIds.add(id);
|
|
26
|
+
const passthrough = getPassthrough?.();
|
|
27
|
+
if (passthrough) {
|
|
28
|
+
await Promise.allSettled(passthrough.map((wf) => {
|
|
29
|
+
return wf.signal(gatedTransactionGoSignal, [
|
|
30
|
+
id
|
|
31
|
+
]);
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const confirmationCallback = /* @__PURE__ */ YJF4D23A_cjs.__name(async (tx) => {
|
|
36
|
+
const id = AYIRG6WY_cjs.getIdForGatedTransaction(tx);
|
|
37
|
+
pendingTransactions[id] = tx;
|
|
38
|
+
await fn.condition(() => approvedIds.has(id) || !!tx.bundleName && approvedBundleNames.has(tx.bundleName));
|
|
39
|
+
tx.bundleName && approvedBundleNames.add(tx.bundleName);
|
|
40
|
+
sentTransactions[id] = tx;
|
|
41
|
+
delete pendingTransactions[id];
|
|
42
|
+
return true;
|
|
43
|
+
}, "confirmationCallback");
|
|
44
|
+
const onResultCallback = /* @__PURE__ */ YJF4D23A_cjs.__name((result) => {
|
|
45
|
+
const id = AYIRG6WY_cjs.getIdForGatedTransaction(result);
|
|
46
|
+
completedTransactions[id] = result;
|
|
47
|
+
delete sentTransactions[id];
|
|
48
|
+
}, "onResultCallback");
|
|
49
|
+
return {
|
|
50
|
+
confirmationCallback,
|
|
51
|
+
onResultCallback
|
|
52
|
+
};
|
|
53
|
+
}, "useGatedTransactionSignalLock");
|
|
54
|
+
|
|
55
|
+
exports.gatedTransactionGoSignal = gatedTransactionGoSignal;
|
|
56
|
+
exports.queryGatedTransactions = queryGatedTransactions;
|
|
57
|
+
exports.useGatedTransactionSignalLock = useGatedTransactionSignalLock;
|
|
58
|
+
//# sourceMappingURL=QGZD4SJ4.cjs.map
|
|
59
|
+
//# sourceMappingURL=QGZD4SJ4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/gatedTransactionSignalLock.ts"],"names":["gatedTransactionGoSignal","defineSignal","queryGatedTransactions","defineQuery","useGatedTransactionSignalLock","__name","fn","getPassthrough","approvedIds","Set","approvedBundleNames","pendingTransactions","sentTransactions","completedTransactions","setHandler","passthroughWfIds","map","handle","workflowId","Object","values","passthroughWorkflowIds","id","add","passthrough","Promise","allSettled","wf","signal","confirmationCallback","tx","getIdForGatedTransaction","condition","has","bundleName","onResultCallback","result"],"mappings":";;;;;;AAkBO,IAAMA,wBAAAA,GACTC,4BAAuC,oBAAA;AACpC,IAAMC,sBAAAA,GACTC,2BAA0C,uBAAA;AAEvC,IAAMC,6BAAAA,mBAAgCC,mBAAA,CAAA,CACzCC,EAAAA,EACAC,cAAAA,KAAAA;AAEA,EAAA,MAAMC,WAAAA,uBAA2CC,GAAAA,EAAAA;AACjD,EAAA,MAAMC,mBAAAA,uBAAuCD,GAAAA,EAAAA;AAE7C,EAAA,MAAME,sBAAoE,EAAC;AAC3E,EAAA,MAAMC,mBAAiE,EAAC;AACxE,EAAA,MAAMC,wBAGF,EAAC;AAELP,EAAAA,EAAAA,CAAGQ,UAAAA,CAAWZ,wBAAwB,MAAA;AAClC,IAAA,MAAMa,mBAAmBR,cAAAA,IAAAA,CAAmBS,MAAM,CAACC,MAAAA,KAAWA,OAAOC,UAAU,CAAA;AAC/E,IAAA,OAAO;MACHP,mBAAAA,EAAqBQ,MAAAA,CAAOC,OAAOT,mBAAAA,CAAAA;MACnCC,gBAAAA,EAAkBO,MAAAA,CAAOC,OAAOR,gBAAAA,CAAAA;MAChCC,qBAAAA,EAAuBM,MAAAA,CAAOC,OAAOP,qBAAAA,CAAAA;AACrCQ,MAAAA,sBAAAA,EAAwBN,oBAAoB;AAChD,KAAA;EACJ,CAAA,CAAA;AAEAT,EAAAA,EAAAA,CAAGQ,UAAAA,CAAWd,wBAAAA,EAA0B,OAAOsB,EAAAA,KAAAA;AAC3Cd,IAAAA,WAAAA,CAAYe,IAAID,EAAAA,CAAAA;AAChB,IAAA,MAAME,cAAcjB,cAAAA,IAAAA;AACpB,IAAA,IAAIiB,WAAAA,EAAa;AACb,MAAA,MAAMC,OAAAA,CAAQC,UAAAA,CACVF,WAAAA,CAAYR,GAAAA,CAAI,CAACW,EAAAA,KAAAA;AACb,QAAA,OAAOA,EAAAA,CAAGC,OAAO5B,wBAAAA,EAA0B;AAACsB,UAAAA;AAAG,SAAA,CAAA;AACnD,MAAA,CAAA,CAAA,CAAA;AAER,IAAA;EACJ,CAAA,CAAA;AAEA,EAAA,MAAMO,oBAAAA,8CAAgFC,EAAAA,KAAAA;AAClF,IAAA,MAAMR,EAAAA,GAAKS,sCAAyBD,EAAAA,CAAAA;AACpCnB,IAAAA,mBAAAA,CAAoBW,EAAAA,CAAAA,GAAMQ,EAAAA;AAE1B,IAAA,MAAMxB,EAAAA,CAAG0B,SAAAA,CACL,MACIxB,WAAAA,CAAYyB,IAAIX,EAAAA,CAAAA,IAAQ,CAAC,CAACQ,GAAGI,UAAAA,IAAcxB,mBAAAA,CAAoBuB,GAAAA,CAAIH,EAAAA,CAAGI,UAAU,CAAA,CAAA;AAGxFJ,IAAAA,EAAAA,CAAGI,UAAAA,IAAcxB,mBAAAA,CAAoBa,GAAAA,CAAIO,EAAAA,CAAGI,UAAU,CAAA;AACtDtB,IAAAA,gBAAAA,CAAiBU,EAAAA,CAAAA,GAAMQ,EAAAA;AACvB,IAAA,OAAOnB,oBAAoBW,EAAAA,CAAAA;AAC3B,IAAA,OAAO,IAAA;EACX,CAAA,EAb+E,sBAAA,CAAA;AAe/E,EAAA,MAAMa,gBAAAA,wCAAkEC,MAAAA,KAAAA;AACpE,IAAA,MAAMd,EAAAA,GAAKS,sCAAyBK,MAAAA,CAAAA;AACpCvB,IAAAA,qBAAAA,CAAsBS,EAAAA,CAAAA,GAAMc,MAAAA;AAC5B,IAAA,OAAOxB,iBAAiBU,EAAAA,CAAAA;EAC5B,CAAA,EAJuE,kBAAA,CAAA;AAMvE,EAAA,OAAO;AAAEO,IAAAA,oBAAAA;AAAsBM,IAAAA;AAAiB,GAAA;AACpD,CAAA,EA1D6C,+BAAA","file":"QGZD4SJ4.cjs","sourcesContent":["import type { WorkflowFunctions, WorkflowHandle } from '@layerzerolabs/common-workflow';\nimport { defineQuery, defineSignal } from '@layerzerolabs/common-workflow';\n\nimport { getIdForGatedTransaction } from './gatedTx';\nimport type {\n GatedTransaction,\n GatedTransactionId,\n GatedTransactionResult,\n UserInteractionCallbacks,\n} from './types';\n\nexport type QueryGatedTransactionsResult = {\n pendingTransactions: GatedTransaction[];\n sentTransactions: GatedTransaction[];\n completedTransactions: (GatedTransaction & { result: GatedTransactionResult })[];\n passthroughWorkflowIds: string[];\n};\n\nexport const gatedTransactionGoSignal =\n defineSignal<[id: GatedTransactionId]>('GatedTransactionGo');\nexport const queryGatedTransactions =\n defineQuery<QueryGatedTransactionsResult>('GatedTransactionQuery');\n\nexport const useGatedTransactionSignalLock = (\n fn: WorkflowFunctions,\n getPassthrough?: () => WorkflowHandle<any>[],\n): UserInteractionCallbacks => {\n const approvedIds: Set<GatedTransactionId> = new Set();\n const approvedBundleNames: Set<string> = new Set();\n\n const pendingTransactions: Record<GatedTransactionId, GatedTransaction> = {};\n const sentTransactions: Record<GatedTransactionId, GatedTransaction> = {};\n const completedTransactions: Record<\n GatedTransactionId,\n GatedTransaction & { result: GatedTransactionResult }\n > = {};\n\n fn.setHandler(queryGatedTransactions, () => {\n const passthroughWfIds = getPassthrough?.().map?.((handle) => handle.workflowId);\n return {\n pendingTransactions: Object.values(pendingTransactions),\n sentTransactions: Object.values(sentTransactions),\n completedTransactions: Object.values(completedTransactions),\n passthroughWorkflowIds: passthroughWfIds ?? [],\n };\n });\n\n fn.setHandler(gatedTransactionGoSignal, async (id) => {\n approvedIds.add(id);\n const passthrough = getPassthrough?.();\n if (passthrough) {\n await Promise.allSettled(\n passthrough.map((wf) => {\n return wf.signal(gatedTransactionGoSignal, [id]);\n }),\n );\n }\n });\n\n const confirmationCallback: UserInteractionCallbacks['confirmationCallback'] = async (tx) => {\n const id = getIdForGatedTransaction(tx);\n pendingTransactions[id] = tx;\n\n await fn.condition(\n () =>\n approvedIds.has(id) || (!!tx.bundleName && approvedBundleNames.has(tx.bundleName)),\n );\n\n tx.bundleName && approvedBundleNames.add(tx.bundleName);\n sentTransactions[id] = tx;\n delete pendingTransactions[id];\n return true;\n };\n\n const onResultCallback: UserInteractionCallbacks['onResultCallback'] = (result) => {\n const id = getIdForGatedTransaction(result);\n completedTransactions[id] = result;\n delete sentTransactions[id];\n };\n\n return { confirmationCallback, onResultCallback };\n};\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var QGZD4SJ4_cjs = require('./QGZD4SJ4.cjs');
|
|
4
|
+
require('./AYIRG6WY.cjs');
|
|
5
|
+
require('./YJF4D23A.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "gatedTransactionGoSignal", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return QGZD4SJ4_cjs.gatedTransactionGoSignal; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "queryGatedTransactions", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return QGZD4SJ4_cjs.queryGatedTransactions; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "useGatedTransactionSignalLock", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return QGZD4SJ4_cjs.useGatedTransactionSignalLock; }
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=gatedTransactionSignalLock.cjs.map
|
|
22
|
+
//# sourceMappingURL=gatedTransactionSignalLock.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"gatedTransactionSignalLock.cjs"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { WorkflowFunctions, WorkflowHandle } from '@layerzerolabs/common-workflow';
|
|
2
|
+
import type { GatedTransaction, GatedTransactionResult, UserInteractionCallbacks } from './types';
|
|
3
|
+
export type QueryGatedTransactionsResult = {
|
|
4
|
+
pendingTransactions: GatedTransaction[];
|
|
5
|
+
sentTransactions: GatedTransaction[];
|
|
6
|
+
completedTransactions: (GatedTransaction & {
|
|
7
|
+
result: GatedTransactionResult;
|
|
8
|
+
})[];
|
|
9
|
+
passthroughWorkflowIds: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare const gatedTransactionGoSignal: import("@layerzerolabs/common-workflow").SignalDefinition<[id: `${string}-${string}-${string}`], string>;
|
|
12
|
+
export declare const queryGatedTransactions: import("@layerzerolabs/common-workflow").QueryDefinition<QueryGatedTransactionsResult, [], string>;
|
|
13
|
+
export declare const useGatedTransactionSignalLock: (fn: WorkflowFunctions, getPassthrough?: () => WorkflowHandle<any>[]) => UserInteractionCallbacks;
|
|
14
|
+
//# sourceMappingURL=gatedTransactionSignalLock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gatedTransactionSignalLock.d.ts","sourceRoot":"","sources":["../src/gatedTransactionSignalLock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAIxF,OAAO,KAAK,EACR,gBAAgB,EAEhB,sBAAsB,EACtB,wBAAwB,EAC3B,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,4BAA4B,GAAG;IACvC,mBAAmB,EAAE,gBAAgB,EAAE,CAAC;IACxC,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;IACrC,qBAAqB,EAAE,CAAC,gBAAgB,GAAG;QAAE,MAAM,EAAE,sBAAsB,CAAA;KAAE,CAAC,EAAE,CAAC;IACjF,sBAAsB,EAAE,MAAM,EAAE,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,wBAAwB,0GAC2B,CAAC;AACjE,eAAO,MAAM,sBAAsB,oGACmC,CAAC;AAEvE,eAAO,MAAM,6BAA6B,GACtC,IAAI,iBAAiB,EACrB,iBAAiB,MAAM,cAAc,CAAC,GAAG,CAAC,EAAE,KAC7C,wBAuDF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { gatedTransactionGoSignal, queryGatedTransactions, useGatedTransactionSignalLock } from './DBJG544E.js';
|
|
2
|
+
import './5INFRBMB.js';
|
|
3
|
+
import './VUOMXK5T.js';
|
|
4
|
+
//# sourceMappingURL=gatedTransactionSignalLock.js.map
|
|
5
|
+
//# sourceMappingURL=gatedTransactionSignalLock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"gatedTransactionSignalLock.js"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var QGZD4SJ4_cjs = require('./QGZD4SJ4.cjs');
|
|
3
4
|
var KX7INHSQ_cjs = require('./KX7INHSQ.cjs');
|
|
4
5
|
var AYIRG6WY_cjs = require('./AYIRG6WY.cjs');
|
|
5
6
|
var BSVO6MXQ_cjs = require('./BSVO6MXQ.cjs');
|
|
@@ -7,6 +8,18 @@ require('./YJF4D23A.cjs');
|
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
11
|
+
Object.defineProperty(exports, "gatedTransactionGoSignal", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return QGZD4SJ4_cjs.gatedTransactionGoSignal; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "queryGatedTransactions", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return QGZD4SJ4_cjs.queryGatedTransactions; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "useGatedTransactionSignalLock", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return QGZD4SJ4_cjs.useGatedTransactionSignalLock; }
|
|
22
|
+
});
|
|
10
23
|
Object.defineProperty(exports, "resolveGatedTransactions", {
|
|
11
24
|
enumerable: true,
|
|
12
25
|
get: function () { return KX7INHSQ_cjs.resolveGatedTransactions; }
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { gatedTransactionGoSignal, queryGatedTransactions, useGatedTransactionSignalLock } from './DBJG544E.js';
|
|
1
2
|
export { resolveGatedTransactions, resolveSequencedGatedTransactions } from './742WLBNW.js';
|
|
2
3
|
export { constructGatedTransaction, getIdForGatedTransaction } from './5INFRBMB.js';
|
|
3
4
|
export { GatedTransactionStatus, gatedTransactionCacheSchema, gatedTransactionResultSchema, gatedTransactionSchema, processedGatedTransactionSchema } from './GLQGPA3F.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/gated-transaction",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"lodash.isequal": "^4.5.0",
|
|
19
19
|
"zod": "^3.23.8",
|
|
20
|
-
"@layerzerolabs/common-activities": "0.0.
|
|
21
|
-
"@layerzerolabs/common-
|
|
22
|
-
"@layerzerolabs/common-
|
|
23
|
-
"@layerzerolabs/
|
|
24
|
-
"@layerzerolabs/
|
|
20
|
+
"@layerzerolabs/common-activities": "0.0.25",
|
|
21
|
+
"@layerzerolabs/common-utils": "0.0.25",
|
|
22
|
+
"@layerzerolabs/common-chain-model": "0.0.25",
|
|
23
|
+
"@layerzerolabs/common-workflow": "0.0.25",
|
|
24
|
+
"@layerzerolabs/zod-utils": "0.0.25"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/lodash.isequal": "^4.5.8",
|
|
28
28
|
"tsup": "^8.4.0",
|
|
29
29
|
"vitest": "^3.2.3",
|
|
30
|
-
"@layerzerolabs/tsup-configuration": "0.0.
|
|
31
|
-
"@layerzerolabs/typescript-configuration": "0.0.
|
|
30
|
+
"@layerzerolabs/tsup-configuration": "0.0.25",
|
|
31
|
+
"@layerzerolabs/typescript-configuration": "0.0.25"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "restricted",
|
|
@@ -36,12 +36,10 @@
|
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsup",
|
|
39
|
-
"
|
|
40
|
-
"checkdeps": "pnpm --filter @layerzerolabs/depcheck run depcheck validate --missing-dependencies --only $npm_package_name",
|
|
39
|
+
"checkdeps": "pnpm --filter @layerzerolabs/depcheck run depcheck validate --catalog --missing-dependencies --only $npm_package_name",
|
|
41
40
|
"clean": "rm -rf ./node_modules .turbo ./dist",
|
|
42
41
|
"dev": "tsup --watch",
|
|
43
|
-
"lint": "eslint . --max-warnings 0",
|
|
44
|
-
"lint:fix": "eslint . --fix --max-warnings 0",
|
|
42
|
+
"lint": "eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)",
|
|
45
43
|
"test": "vitest --run --pass-with-no-tests"
|
|
46
44
|
}
|
|
47
45
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { WorkflowFunctions, WorkflowHandle } from '@layerzerolabs/common-workflow';
|
|
2
|
+
import { defineQuery, defineSignal } from '@layerzerolabs/common-workflow';
|
|
3
|
+
|
|
4
|
+
import { getIdForGatedTransaction } from './gatedTx';
|
|
5
|
+
import type {
|
|
6
|
+
GatedTransaction,
|
|
7
|
+
GatedTransactionId,
|
|
8
|
+
GatedTransactionResult,
|
|
9
|
+
UserInteractionCallbacks,
|
|
10
|
+
} from './types';
|
|
11
|
+
|
|
12
|
+
export type QueryGatedTransactionsResult = {
|
|
13
|
+
pendingTransactions: GatedTransaction[];
|
|
14
|
+
sentTransactions: GatedTransaction[];
|
|
15
|
+
completedTransactions: (GatedTransaction & { result: GatedTransactionResult })[];
|
|
16
|
+
passthroughWorkflowIds: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const gatedTransactionGoSignal =
|
|
20
|
+
defineSignal<[id: GatedTransactionId]>('GatedTransactionGo');
|
|
21
|
+
export const queryGatedTransactions =
|
|
22
|
+
defineQuery<QueryGatedTransactionsResult>('GatedTransactionQuery');
|
|
23
|
+
|
|
24
|
+
export const useGatedTransactionSignalLock = (
|
|
25
|
+
fn: WorkflowFunctions,
|
|
26
|
+
getPassthrough?: () => WorkflowHandle<any>[],
|
|
27
|
+
): UserInteractionCallbacks => {
|
|
28
|
+
const approvedIds: Set<GatedTransactionId> = new Set();
|
|
29
|
+
const approvedBundleNames: Set<string> = new Set();
|
|
30
|
+
|
|
31
|
+
const pendingTransactions: Record<GatedTransactionId, GatedTransaction> = {};
|
|
32
|
+
const sentTransactions: Record<GatedTransactionId, GatedTransaction> = {};
|
|
33
|
+
const completedTransactions: Record<
|
|
34
|
+
GatedTransactionId,
|
|
35
|
+
GatedTransaction & { result: GatedTransactionResult }
|
|
36
|
+
> = {};
|
|
37
|
+
|
|
38
|
+
fn.setHandler(queryGatedTransactions, () => {
|
|
39
|
+
const passthroughWfIds = getPassthrough?.().map?.((handle) => handle.workflowId);
|
|
40
|
+
return {
|
|
41
|
+
pendingTransactions: Object.values(pendingTransactions),
|
|
42
|
+
sentTransactions: Object.values(sentTransactions),
|
|
43
|
+
completedTransactions: Object.values(completedTransactions),
|
|
44
|
+
passthroughWorkflowIds: passthroughWfIds ?? [],
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
fn.setHandler(gatedTransactionGoSignal, async (id) => {
|
|
49
|
+
approvedIds.add(id);
|
|
50
|
+
const passthrough = getPassthrough?.();
|
|
51
|
+
if (passthrough) {
|
|
52
|
+
await Promise.allSettled(
|
|
53
|
+
passthrough.map((wf) => {
|
|
54
|
+
return wf.signal(gatedTransactionGoSignal, [id]);
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const confirmationCallback: UserInteractionCallbacks['confirmationCallback'] = async (tx) => {
|
|
61
|
+
const id = getIdForGatedTransaction(tx);
|
|
62
|
+
pendingTransactions[id] = tx;
|
|
63
|
+
|
|
64
|
+
await fn.condition(
|
|
65
|
+
() =>
|
|
66
|
+
approvedIds.has(id) || (!!tx.bundleName && approvedBundleNames.has(tx.bundleName)),
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
tx.bundleName && approvedBundleNames.add(tx.bundleName);
|
|
70
|
+
sentTransactions[id] = tx;
|
|
71
|
+
delete pendingTransactions[id];
|
|
72
|
+
return true;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const onResultCallback: UserInteractionCallbacks['onResultCallback'] = (result) => {
|
|
76
|
+
const id = getIdForGatedTransaction(result);
|
|
77
|
+
completedTransactions[id] = result;
|
|
78
|
+
delete sentTransactions[id];
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return { confirmationCallback, onResultCallback };
|
|
82
|
+
};
|
package/src/index.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -16,13 +16,5 @@
|
|
|
16
16
|
"**/*.test.ts",
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
|
-
"include": ["src/**/*"]
|
|
20
|
-
"ts-node": {
|
|
21
|
-
"files": true,
|
|
22
|
-
"experimentalResolverFeatures": true,
|
|
23
|
-
"compilerOptions": {
|
|
24
|
-
"module": "CommonJS",
|
|
25
|
-
"types": ["node"]
|
|
26
|
-
}
|
|
27
|
-
}
|
|
19
|
+
"include": ["src/**/*"]
|
|
28
20
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @layerzerolabs/gated-transaction@0.0.0 checkcatalog /home/runner/work/monorepo-internal/monorepo-internal/packages/gated-transaction
|
|
3
|
-
> pnpm --filter @layerzerolabs/depcheck run depcheck validate --catalog --only $npm_package_name
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
> @layerzerolabs/depcheck@1.0.1 depcheck /home/runner/work/monorepo-internal/monorepo-internal/tools/repo/depcheck
|
|
7
|
-
> tsx ./src/index.ts "validate" "--catalog" "--only" "@layerzerolabs/gated-transaction"
|
|
8
|
-
|