@recoillink/aleo-sdk 0.0.0-stage → 45.0.1
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/LICENSE.md +193 -0
- package/README.md +56 -2
- package/dist/artifacts.d.ts +14 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +23 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/clients/base.d.ts +27 -0
- package/dist/clients/base.d.ts.map +1 -0
- package/dist/clients/base.js +105 -0
- package/dist/clients/base.js.map +1 -0
- package/dist/clients/protocol.d.ts +26 -0
- package/dist/clients/protocol.d.ts.map +1 -0
- package/dist/clients/protocol.js +104 -0
- package/dist/clients/protocol.js.map +1 -0
- package/dist/clients/provider.d.ts +42 -0
- package/dist/clients/provider.d.ts.map +1 -0
- package/dist/clients/provider.js +460 -0
- package/dist/clients/provider.js.map +1 -0
- package/dist/clients/provider.node.d.ts +7 -0
- package/dist/clients/provider.node.d.ts.map +1 -0
- package/dist/clients/provider.node.js +20 -0
- package/dist/clients/provider.node.js.map +1 -0
- package/dist/clients/signer.d.ts +32 -0
- package/dist/clients/signer.d.ts.map +1 -0
- package/dist/clients/signer.js +137 -0
- package/dist/clients/signer.js.map +1 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +8 -0
- package/dist/constants.js.map +1 -0
- package/dist/hook/base.d.ts +19 -0
- package/dist/hook/base.d.ts.map +1 -0
- package/dist/hook/base.js +29 -0
- package/dist/hook/base.js.map +1 -0
- package/dist/hook/hook-artifact-manager.d.ts +25 -0
- package/dist/hook/hook-artifact-manager.d.ts.map +1 -0
- package/dist/hook/hook-artifact-manager.js +62 -0
- package/dist/hook/hook-artifact-manager.js.map +1 -0
- package/dist/hook/hook-query.d.ts +44 -0
- package/dist/hook/hook-query.d.ts.map +1 -0
- package/dist/hook/hook-query.js +103 -0
- package/dist/hook/hook-query.js.map +1 -0
- package/dist/hook/hook-tx.d.ts +46 -0
- package/dist/hook/hook-tx.d.ts.map +1 -0
- package/dist/hook/hook-tx.js +89 -0
- package/dist/hook/hook-tx.js.map +1 -0
- package/dist/hook/igp-hook.d.ts +21 -0
- package/dist/hook/igp-hook.d.ts.map +1 -0
- package/dist/hook/igp-hook.js +145 -0
- package/dist/hook/igp-hook.js.map +1 -0
- package/dist/hook/merkle-tree-hook.d.ts +21 -0
- package/dist/hook/merkle-tree-hook.d.ts.map +1 -0
- package/dist/hook/merkle-tree-hook.js +58 -0
- package/dist/hook/merkle-tree-hook.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/ism/base.d.ts +15 -0
- package/dist/ism/base.d.ts.map +1 -0
- package/dist/ism/base.js +25 -0
- package/dist/ism/base.js.map +1 -0
- package/dist/ism/ism-artifact-manager.d.ts +12 -0
- package/dist/ism/ism-artifact-manager.d.ts.map +1 -0
- package/dist/ism/ism-artifact-manager.js +62 -0
- package/dist/ism/ism-artifact-manager.js.map +1 -0
- package/dist/ism/ism-query.d.ts +51 -0
- package/dist/ism/ism-query.d.ts.map +1 -0
- package/dist/ism/ism-query.js +155 -0
- package/dist/ism/ism-query.js.map +1 -0
- package/dist/ism/ism-tx.d.ts +14 -0
- package/dist/ism/ism-tx.d.ts.map +1 -0
- package/dist/ism/ism-tx.js +77 -0
- package/dist/ism/ism-tx.js.map +1 -0
- package/dist/ism/multisig-ism.d.ts +20 -0
- package/dist/ism/multisig-ism.d.ts.map +1 -0
- package/dist/ism/multisig-ism.js +56 -0
- package/dist/ism/multisig-ism.js.map +1 -0
- package/dist/ism/routing-ism.d.ts +20 -0
- package/dist/ism/routing-ism.d.ts.map +1 -0
- package/dist/ism/routing-ism.js +108 -0
- package/dist/ism/routing-ism.js.map +1 -0
- package/dist/ism/test-ism.d.ts +20 -0
- package/dist/ism/test-ism.d.ts.map +1 -0
- package/dist/ism/test-ism.js +50 -0
- package/dist/ism/test-ism.js.map +1 -0
- package/dist/mailbox/mailbox-artifact-manager.d.ts +21 -0
- package/dist/mailbox/mailbox-artifact-manager.d.ts.map +1 -0
- package/dist/mailbox/mailbox-artifact-manager.js +36 -0
- package/dist/mailbox/mailbox-artifact-manager.js.map +1 -0
- package/dist/mailbox/mailbox-query.d.ts +12 -0
- package/dist/mailbox/mailbox-query.d.ts.map +1 -0
- package/dist/mailbox/mailbox-query.js +33 -0
- package/dist/mailbox/mailbox-query.js.map +1 -0
- package/dist/mailbox/mailbox-tx.d.ts +42 -0
- package/dist/mailbox/mailbox-tx.d.ts.map +1 -0
- package/dist/mailbox/mailbox-tx.js +94 -0
- package/dist/mailbox/mailbox-tx.js.map +1 -0
- package/dist/mailbox/mailbox.d.ts +29 -0
- package/dist/mailbox/mailbox.d.ts.map +1 -0
- package/dist/mailbox/mailbox.js +165 -0
- package/dist/mailbox/mailbox.js.map +1 -0
- package/dist/programs.d.ts +3 -0
- package/dist/programs.d.ts.map +1 -0
- package/dist/programs.js +14 -0
- package/dist/programs.js.map +1 -0
- package/dist/runtime/mainnet.d.ts +3 -0
- package/dist/runtime/mainnet.d.ts.map +1 -0
- package/dist/runtime/mainnet.js +5 -0
- package/dist/runtime/mainnet.js.map +1 -0
- package/dist/runtime/provider.d.ts +10 -0
- package/dist/runtime/provider.d.ts.map +1 -0
- package/dist/runtime/provider.js +18 -0
- package/dist/runtime/provider.js.map +1 -0
- package/dist/runtime/provider.test.d.ts +2 -0
- package/dist/runtime/provider.test.d.ts.map +1 -0
- package/dist/runtime/provider.test.js +45 -0
- package/dist/runtime/provider.test.js.map +1 -0
- package/dist/runtime/testnet.d.ts +3 -0
- package/dist/runtime/testnet.d.ts.map +1 -0
- package/dist/runtime/testnet.js +8 -0
- package/dist/runtime/testnet.js.map +1 -0
- package/dist/runtime.d.ts +5 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +4 -0
- package/dist/runtime.js.map +1 -0
- package/dist/testing/constants.d.ts +58 -0
- package/dist/testing/constants.d.ts.map +1 -0
- package/dist/testing/constants.js +60 -0
- package/dist/testing/constants.js.map +1 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +7 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/node.d.ts +10 -0
- package/dist/testing/node.d.ts.map +1 -0
- package/dist/testing/node.js +39 -0
- package/dist/testing/node.js.map +1 -0
- package/dist/testing/utils.d.ts +19 -0
- package/dist/testing/utils.d.ts.map +1 -0
- package/dist/testing/utils.js +23 -0
- package/dist/testing/utils.js.map +1 -0
- package/dist/tests/5_ism_artifacts.e2e-test.d.ts +2 -0
- package/dist/tests/5_ism_artifacts.e2e-test.d.ts.map +1 -0
- package/dist/tests/5_ism_artifacts.e2e-test.js +415 -0
- package/dist/tests/5_ism_artifacts.e2e-test.js.map +1 -0
- package/dist/tests/6_hook_artifacts.e2e-test.d.ts +2 -0
- package/dist/tests/6_hook_artifacts.e2e-test.d.ts.map +1 -0
- package/dist/tests/6_hook_artifacts.e2e-test.js +306 -0
- package/dist/tests/6_hook_artifacts.e2e-test.js.map +1 -0
- package/dist/tests/7a_warp_native_artifacts.e2e-test.d.ts +2 -0
- package/dist/tests/7a_warp_native_artifacts.e2e-test.d.ts.map +1 -0
- package/dist/tests/7a_warp_native_artifacts.e2e-test.js +105 -0
- package/dist/tests/7a_warp_native_artifacts.e2e-test.js.map +1 -0
- package/dist/tests/7b_warp_collateral_artifacts.e2e-test.d.ts +2 -0
- package/dist/tests/7b_warp_collateral_artifacts.e2e-test.d.ts.map +1 -0
- package/dist/tests/7b_warp_collateral_artifacts.e2e-test.js +144 -0
- package/dist/tests/7b_warp_collateral_artifacts.e2e-test.js.map +1 -0
- package/dist/tests/7c_warp_synthetic_artifacts.e2e-test.d.ts +2 -0
- package/dist/tests/7c_warp_synthetic_artifacts.e2e-test.d.ts.map +1 -0
- package/dist/tests/7c_warp_synthetic_artifacts.e2e-test.js +99 -0
- package/dist/tests/7c_warp_synthetic_artifacts.e2e-test.js.map +1 -0
- package/dist/tests/8_mailbox_artifacts.e2e-test.d.ts +2 -0
- package/dist/tests/8_mailbox_artifacts.e2e-test.d.ts.map +1 -0
- package/dist/tests/8_mailbox_artifacts.e2e-test.js +395 -0
- package/dist/tests/8_mailbox_artifacts.e2e-test.js.map +1 -0
- package/dist/tests/9_validator_announce_artifacts.e2e-test.d.ts +2 -0
- package/dist/tests/9_validator_announce_artifacts.e2e-test.d.ts.map +1 -0
- package/dist/tests/9_validator_announce_artifacts.e2e-test.js +138 -0
- package/dist/tests/9_validator_announce_artifacts.e2e-test.js.map +1 -0
- package/dist/tests/e2e-test.setup.d.ts +2 -0
- package/dist/tests/e2e-test.setup.d.ts.map +1 -0
- package/dist/tests/e2e-test.setup.js +33 -0
- package/dist/tests/e2e-test.setup.js.map +1 -0
- package/dist/tests/warp-artifact-test-suite.d.ts +34 -0
- package/dist/tests/warp-artifact-test-suite.d.ts.map +1 -0
- package/dist/tests/warp-artifact-test-suite.js +672 -0
- package/dist/tests/warp-artifact-test-suite.js.map +1 -0
- package/dist/utils/base-query.d.ts +50 -0
- package/dist/utils/base-query.d.ts.map +1 -0
- package/dist/utils/base-query.js +72 -0
- package/dist/utils/base-query.js.map +1 -0
- package/dist/utils/helper.crypto.d.ts +4 -0
- package/dist/utils/helper.crypto.d.ts.map +1 -0
- package/dist/utils/helper.crypto.js +12 -0
- package/dist/utils/helper.crypto.js.map +1 -0
- package/dist/utils/helper.d.ts +63 -0
- package/dist/utils/helper.d.ts.map +1 -0
- package/dist/utils/helper.js +291 -0
- package/dist/utils/helper.js.map +1 -0
- package/dist/utils/helper.node.d.ts +9 -0
- package/dist/utils/helper.node.d.ts.map +1 -0
- package/dist/utils/helper.node.js +159 -0
- package/dist/utils/helper.node.js.map +1 -0
- package/dist/utils/helper.test.d.ts +2 -0
- package/dist/utils/helper.test.d.ts.map +1 -0
- package/dist/utils/helper.test.js +22 -0
- package/dist/utils/helper.test.js.map +1 -0
- package/dist/utils/provable.d.ts +4 -0
- package/dist/utils/provable.d.ts.map +1 -0
- package/dist/utils/provable.js +2 -0
- package/dist/utils/provable.js.map +1 -0
- package/dist/utils/types.d.ts +104 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +64 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/validator-announce/validator-announce-artifact-manager.d.ts +21 -0
- package/dist/validator-announce/validator-announce-artifact-manager.d.ts.map +1 -0
- package/dist/validator-announce/validator-announce-artifact-manager.js +27 -0
- package/dist/validator-announce/validator-announce-artifact-manager.js.map +1 -0
- package/dist/validator-announce/validator-announce-query.d.ts +15 -0
- package/dist/validator-announce/validator-announce-query.d.ts.map +1 -0
- package/dist/validator-announce/validator-announce-query.js +32 -0
- package/dist/validator-announce/validator-announce-query.js.map +1 -0
- package/dist/validator-announce/validator-announce-tx.d.ts +11 -0
- package/dist/validator-announce/validator-announce-tx.d.ts.map +1 -0
- package/dist/validator-announce/validator-announce-tx.js +20 -0
- package/dist/validator-announce/validator-announce-tx.js.map +1 -0
- package/dist/validator-announce/validator-announce.d.ts +29 -0
- package/dist/validator-announce/validator-announce.d.ts.map +1 -0
- package/dist/validator-announce/validator-announce.js +71 -0
- package/dist/validator-announce/validator-announce.js.map +1 -0
- package/dist/warp/collateral-token.d.ts +21 -0
- package/dist/warp/collateral-token.d.ts.map +1 -0
- package/dist/warp/collateral-token.js +108 -0
- package/dist/warp/collateral-token.js.map +1 -0
- package/dist/warp/native-token.d.ts +21 -0
- package/dist/warp/native-token.d.ts.map +1 -0
- package/dist/warp/native-token.js +114 -0
- package/dist/warp/native-token.js.map +1 -0
- package/dist/warp/provider-query.d.ts +22 -0
- package/dist/warp/provider-query.d.ts.map +1 -0
- package/dist/warp/provider-query.js +89 -0
- package/dist/warp/provider-query.js.map +1 -0
- package/dist/warp/synthetic-token.d.ts +21 -0
- package/dist/warp/synthetic-token.d.ts.map +1 -0
- package/dist/warp/synthetic-token.js +108 -0
- package/dist/warp/synthetic-token.js.map +1 -0
- package/dist/warp/warp-artifact-manager.d.ts +15 -0
- package/dist/warp/warp-artifact-manager.d.ts.map +1 -0
- package/dist/warp/warp-artifact-manager.js +48 -0
- package/dist/warp/warp-artifact-manager.js.map +1 -0
- package/dist/warp/warp-query.d.ts +76 -0
- package/dist/warp/warp-query.d.ts.map +1 -0
- package/dist/warp/warp-query.js +321 -0
- package/dist/warp/warp-query.js.map +1 -0
- package/dist/warp/warp-query.test.d.ts +2 -0
- package/dist/warp/warp-query.test.d.ts.map +1 -0
- package/dist/warp/warp-query.test.js +270 -0
- package/dist/warp/warp-query.test.js.map +1 -0
- package/dist/warp/warp-tx.d.ts +58 -0
- package/dist/warp/warp-tx.d.ts.map +1 -0
- package/dist/warp/warp-tx.js +229 -0
- package/dist/warp/warp-tx.js.map +1 -0
- package/dist/warp/warp-tx.test.d.ts +2 -0
- package/dist/warp/warp-tx.test.d.ts.map +1 -0
- package/dist/warp/warp-tx.test.js +44 -0
- package/dist/warp/warp-tx.test.js.map +1 -0
- package/package.json +91 -3
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { AltVM } from '@recoillink/provider-sdk';
|
|
3
|
+
import { ArtifactState } from '@recoillink/provider-sdk/artifact';
|
|
4
|
+
import { assert, eqAddressAleo } from '@recoillink/utils';
|
|
5
|
+
import { TEST_ALEO_BURN_ADDRESS } from '../testing/constants.js';
|
|
6
|
+
const DOMAIN_1 = 42;
|
|
7
|
+
const DOMAIN_2 = 96;
|
|
8
|
+
/**
|
|
9
|
+
* Shared test suite for warp token artifact CRUD, ISM updates, hook updates,
|
|
10
|
+
* and generic readWarpToken. Call inside a `describe` block after setting up
|
|
11
|
+
* the context in a `before` hook.
|
|
12
|
+
*/
|
|
13
|
+
export function warpArtifactTestSuite(getContext, testCase) {
|
|
14
|
+
const { type, getConfig, expectedFields } = testCase;
|
|
15
|
+
let ctx;
|
|
16
|
+
before(() => {
|
|
17
|
+
ctx = getContext();
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Returns a deployed token in the requested initial config state.
|
|
21
|
+
* When ctx.preDeployedToken is set, resets the shared token to match
|
|
22
|
+
* the given config via update transactions instead of deploying fresh.
|
|
23
|
+
*/
|
|
24
|
+
async function getDeployedToken(config) {
|
|
25
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
26
|
+
if (ctx.preDeployedToken) {
|
|
27
|
+
const target = {
|
|
28
|
+
...ctx.preDeployedToken,
|
|
29
|
+
config: {
|
|
30
|
+
...ctx.preDeployedToken.config,
|
|
31
|
+
remoteRouters: config.remoteRouters ?? {},
|
|
32
|
+
destinationGas: config.destinationGas ?? {},
|
|
33
|
+
interchainSecurityModule: config.interchainSecurityModule,
|
|
34
|
+
hook: config.hook,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const txs = await writer.update(target);
|
|
38
|
+
for (const tx of txs) {
|
|
39
|
+
await ctx.providerSdkSigner.sendAndConfirmTransaction(tx);
|
|
40
|
+
}
|
|
41
|
+
return target;
|
|
42
|
+
}
|
|
43
|
+
const [deployed] = await writer.create({ config });
|
|
44
|
+
return deployed;
|
|
45
|
+
}
|
|
46
|
+
it('should create and read token', async () => {
|
|
47
|
+
const config = getConfig();
|
|
48
|
+
if (ctx.preDeployedToken) {
|
|
49
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
50
|
+
const readToken = await reader.read(ctx.preDeployedToken.deployed.address);
|
|
51
|
+
expect(readToken.artifactState).to.equal(ArtifactState.DEPLOYED);
|
|
52
|
+
expect(readToken.config.type).to.equal(type);
|
|
53
|
+
expect(readToken.deployed.address).to.equal(ctx.preDeployedToken.deployed.address);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
57
|
+
const [result, receipts] = await writer.create({ config });
|
|
58
|
+
expect(result.artifactState).to.equal(ArtifactState.DEPLOYED);
|
|
59
|
+
expect(result.config.type).to.equal(type);
|
|
60
|
+
expect(result.deployed.address).to.be.a('string').and.not.be.empty;
|
|
61
|
+
expect(receipts).to.be.an('array').with.length.greaterThan(0);
|
|
62
|
+
// Read back the token
|
|
63
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
64
|
+
const readToken = await reader.read(result.deployed.address);
|
|
65
|
+
expect(readToken.artifactState).to.equal(ArtifactState.DEPLOYED);
|
|
66
|
+
expect(readToken.config.type).to.equal(type);
|
|
67
|
+
expect(readToken.deployed.address).to.equal(result.deployed.address);
|
|
68
|
+
// Verify expected fields
|
|
69
|
+
if (expectedFields) {
|
|
70
|
+
for (const [field, expectedValue] of Object.entries(expectedFields)) {
|
|
71
|
+
expect(readToken.config[field]).to.equal(expectedValue);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
it('should enroll remote routers', async () => {
|
|
76
|
+
const initialConfig = getConfig();
|
|
77
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
78
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
79
|
+
// Update with remote routers
|
|
80
|
+
const updatedConfig = {
|
|
81
|
+
...deployedToken,
|
|
82
|
+
config: {
|
|
83
|
+
...deployedToken.config,
|
|
84
|
+
remoteRouters: {
|
|
85
|
+
[DOMAIN_1]: {
|
|
86
|
+
address: '0xe98b09dff7176053c651a4dc025af3e4f6a442415e9b85dd076ac0ff66b4b1ed',
|
|
87
|
+
},
|
|
88
|
+
[DOMAIN_2]: {
|
|
89
|
+
address: '0x1aac830e4d71000c25149af643b5a18c7a907e2d36147d8b57c5847b03ea5528',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
destinationGas: {
|
|
93
|
+
[DOMAIN_1]: '100000',
|
|
94
|
+
[DOMAIN_2]: '200000',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
const txs = await writer.update(updatedConfig);
|
|
99
|
+
expect(txs).to.be.an('array').with.length.greaterThan(0);
|
|
100
|
+
for (const tx of txs) {
|
|
101
|
+
await ctx.providerSdkSigner.sendAndConfirmTransaction(tx);
|
|
102
|
+
}
|
|
103
|
+
// Verify
|
|
104
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
105
|
+
const readToken = await reader.read(deployedToken.deployed.address);
|
|
106
|
+
const domain1Router = readToken.config.remoteRouters[DOMAIN_1];
|
|
107
|
+
const domain2Router = readToken.config.remoteRouters[DOMAIN_2];
|
|
108
|
+
assert(domain1Router, `Missing remote router for ${DOMAIN_1}`);
|
|
109
|
+
assert(domain2Router, `Missing remote router for ${DOMAIN_2}`);
|
|
110
|
+
expect(domain1Router.address).to.equal('0xe98b09dff7176053c651a4dc025af3e4f6a442415e9b85dd076ac0ff66b4b1ed');
|
|
111
|
+
expect(domain2Router.address).to.equal('0x1aac830e4d71000c25149af643b5a18c7a907e2d36147d8b57c5847b03ea5528');
|
|
112
|
+
expect(readToken.config.destinationGas[DOMAIN_1]).to.equal('100000');
|
|
113
|
+
expect(readToken.config.destinationGas[DOMAIN_2]).to.equal('200000');
|
|
114
|
+
});
|
|
115
|
+
it('should unenroll removed routers', async () => {
|
|
116
|
+
const initialConfig = getConfig();
|
|
117
|
+
initialConfig.remoteRouters = {
|
|
118
|
+
[DOMAIN_1]: {
|
|
119
|
+
address: '0xc2c6885c3c9e16064d86ce46b7a1ac57888a1e60b2ce88d2504347d3418399c4',
|
|
120
|
+
},
|
|
121
|
+
[DOMAIN_2]: {
|
|
122
|
+
address: '0x1aac830e4d71000c25149af643b5a18c7a907e2d36147d8b57c5847b03ea5528',
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
initialConfig.destinationGas = {
|
|
126
|
+
[DOMAIN_1]: '100000',
|
|
127
|
+
[DOMAIN_2]: '200000',
|
|
128
|
+
};
|
|
129
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
130
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
131
|
+
// Remove DOMAIN_2
|
|
132
|
+
const updatedConfig = {
|
|
133
|
+
...deployedToken,
|
|
134
|
+
config: {
|
|
135
|
+
...deployedToken.config,
|
|
136
|
+
remoteRouters: {
|
|
137
|
+
[DOMAIN_1]: {
|
|
138
|
+
address: '0xc2c6885c3c9e16064d86ce46b7a1ac57888a1e60b2ce88d2504347d3418399c4',
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
destinationGas: {
|
|
142
|
+
[DOMAIN_1]: '100000',
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
const txs = await writer.update(updatedConfig);
|
|
147
|
+
expect(txs).to.be.an('array').with.length.greaterThan(0);
|
|
148
|
+
for (const tx of txs) {
|
|
149
|
+
await ctx.providerSdkSigner.sendAndConfirmTransaction(tx);
|
|
150
|
+
}
|
|
151
|
+
// Verify DOMAIN_2 was unenrolled
|
|
152
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
153
|
+
const readToken = await reader.read(deployedToken.deployed.address);
|
|
154
|
+
expect(readToken.config.remoteRouters[DOMAIN_1]).to.exist;
|
|
155
|
+
expect(readToken.config.remoteRouters[DOMAIN_2]).to.be.undefined;
|
|
156
|
+
});
|
|
157
|
+
it('should update when only destination gas changes', async () => {
|
|
158
|
+
const initialConfig = getConfig();
|
|
159
|
+
const routerAddress = '0xc2c6885c3c9e16064d86ce46b7a1ac57888a1e60b2ce88d2504347d3418399c4';
|
|
160
|
+
// Create with initial gas value
|
|
161
|
+
initialConfig.remoteRouters = {
|
|
162
|
+
[DOMAIN_1]: { address: routerAddress },
|
|
163
|
+
};
|
|
164
|
+
initialConfig.destinationGas = {
|
|
165
|
+
[DOMAIN_1]: '100000',
|
|
166
|
+
};
|
|
167
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
168
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
169
|
+
// Verify initial gas value
|
|
170
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
171
|
+
const readToken1 = await reader.read(deployedToken.deployed.address);
|
|
172
|
+
expect(readToken1.config.destinationGas[DOMAIN_1]).to.equal('100000');
|
|
173
|
+
// Update only gas (router address unchanged)
|
|
174
|
+
const updatedConfig = {
|
|
175
|
+
...deployedToken,
|
|
176
|
+
config: {
|
|
177
|
+
...deployedToken.config,
|
|
178
|
+
remoteRouters: {
|
|
179
|
+
[DOMAIN_1]: { address: routerAddress }, // Same address
|
|
180
|
+
},
|
|
181
|
+
destinationGas: {
|
|
182
|
+
[DOMAIN_1]: '200000', // Changed gas
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
const txs = await writer.update(updatedConfig);
|
|
187
|
+
expect(txs).to.be.an('array').with.length.greaterThan(0);
|
|
188
|
+
// Execute update
|
|
189
|
+
for (const tx of txs) {
|
|
190
|
+
await ctx.providerSdkSigner.sendAndConfirmTransaction(tx);
|
|
191
|
+
}
|
|
192
|
+
// Verify gas changed
|
|
193
|
+
const readToken2 = await reader.read(deployedToken.deployed.address);
|
|
194
|
+
const domain1Router = readToken2.config.remoteRouters[DOMAIN_1];
|
|
195
|
+
assert(domain1Router, `Missing remote router for ${DOMAIN_1}`);
|
|
196
|
+
expect(readToken2.config.destinationGas[DOMAIN_1]).to.equal('200000');
|
|
197
|
+
expect(eqAddressAleo(domain1Router.address, routerAddress)).to.be.true;
|
|
198
|
+
});
|
|
199
|
+
it('should transfer ownership via update (ownership last)', async () => {
|
|
200
|
+
if (ctx.preDeployedToken) {
|
|
201
|
+
// Ownership transfer is irreversible — skip to avoid breaking subsequent tests
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const initialConfig = getConfig();
|
|
205
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
206
|
+
const [deployedToken] = await writer.create({
|
|
207
|
+
config: initialConfig,
|
|
208
|
+
});
|
|
209
|
+
const customIsmAddress = TEST_ALEO_BURN_ADDRESS;
|
|
210
|
+
// Update routers, ISM, AND ownership
|
|
211
|
+
const updatedConfig = {
|
|
212
|
+
...deployedToken,
|
|
213
|
+
config: {
|
|
214
|
+
...deployedToken.config,
|
|
215
|
+
owner: TEST_ALEO_BURN_ADDRESS,
|
|
216
|
+
interchainSecurityModule: {
|
|
217
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
218
|
+
deployed: {
|
|
219
|
+
address: customIsmAddress,
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
remoteRouters: {
|
|
223
|
+
[DOMAIN_1]: {
|
|
224
|
+
address: '0xc2c6885c3c9e16064d86ce46b7a1ac57888a1e60b2ce88d2504347d3418399c4',
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
destinationGas: {
|
|
228
|
+
[DOMAIN_1]: '100000',
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
const txs = await writer.update(updatedConfig);
|
|
233
|
+
expect(txs).to.be.an('array').with.length.greaterThan(0);
|
|
234
|
+
// Verify ownership transfer is the LAST transaction
|
|
235
|
+
const lastTx = txs[txs.length - 1];
|
|
236
|
+
assert(lastTx, 'Expected at least one ownership update transaction');
|
|
237
|
+
expect(lastTx.annotation).to.include('owner');
|
|
238
|
+
// Execute all transactions
|
|
239
|
+
for (const tx of txs) {
|
|
240
|
+
await ctx.providerSdkSigner.sendAndConfirmTransaction(tx);
|
|
241
|
+
}
|
|
242
|
+
// Verify router enrollment, ISM, AND ownership transfer succeeded
|
|
243
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
244
|
+
const readToken = await reader.read(deployedToken.deployed.address);
|
|
245
|
+
const domain1Router = readToken.config.remoteRouters[DOMAIN_1];
|
|
246
|
+
assert(domain1Router, `Missing remote router for ${DOMAIN_1}`);
|
|
247
|
+
expect(domain1Router.address).to.equal('0xc2c6885c3c9e16064d86ce46b7a1ac57888a1e60b2ce88d2504347d3418399c4');
|
|
248
|
+
expect(readToken.config.interchainSecurityModule?.deployed.address).to.be
|
|
249
|
+
.undefined;
|
|
250
|
+
expect(eqAddressAleo(readToken.config.owner, TEST_ALEO_BURN_ADDRESS)).to.be
|
|
251
|
+
.true;
|
|
252
|
+
});
|
|
253
|
+
it('should return no update transactions when config is unchanged', async () => {
|
|
254
|
+
const config = getConfig();
|
|
255
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
256
|
+
const deployedToken = await getDeployedToken(config);
|
|
257
|
+
const txs = await writer.update(deployedToken);
|
|
258
|
+
expect(txs).to.be.an('array').with.length(0);
|
|
259
|
+
});
|
|
260
|
+
describe('ISM updates', function () {
|
|
261
|
+
it('should unset ISM when changed from address to undefined', async () => {
|
|
262
|
+
const initialConfig = getConfig();
|
|
263
|
+
const ismWriter = ctx.ismArtifactManager.createWriter(AltVM.IsmType.TEST_ISM, ctx.aleoSigner);
|
|
264
|
+
const [deployedIsm] = await ismWriter.create({
|
|
265
|
+
config: { type: AltVM.IsmType.TEST_ISM },
|
|
266
|
+
});
|
|
267
|
+
const customIsmAddress = deployedIsm.deployed.address;
|
|
268
|
+
// Create with ISM set
|
|
269
|
+
initialConfig.interchainSecurityModule = {
|
|
270
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
271
|
+
deployed: {
|
|
272
|
+
address: customIsmAddress,
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
276
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
277
|
+
// Verify ISM is set
|
|
278
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
279
|
+
const readToken1 = await reader.read(deployedToken.deployed.address);
|
|
280
|
+
assert(readToken1.config.interchainSecurityModule?.deployed.address, 'ISM address should exist');
|
|
281
|
+
expect(eqAddressAleo(readToken1.config.interchainSecurityModule.deployed.address, customIsmAddress)).to.be.true;
|
|
282
|
+
// Update to clear ISM (set to undefined)
|
|
283
|
+
const updatedConfig = {
|
|
284
|
+
...deployedToken,
|
|
285
|
+
config: {
|
|
286
|
+
...deployedToken.config,
|
|
287
|
+
interchainSecurityModule: undefined,
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
const txs = await writer.update(updatedConfig);
|
|
291
|
+
expect(txs).to.be.an('array').with.length.greaterThan(0);
|
|
292
|
+
// Execute update
|
|
293
|
+
for (const tx of txs) {
|
|
294
|
+
await ctx.providerSdkSigner.sendAndConfirmTransaction(tx);
|
|
295
|
+
}
|
|
296
|
+
// Verify ISM is now unset
|
|
297
|
+
const readToken2 = await reader.read(deployedToken.deployed.address);
|
|
298
|
+
expect(readToken2.config.interchainSecurityModule).to.be.undefined;
|
|
299
|
+
});
|
|
300
|
+
it('should set ISM when changed from undefined to address', async () => {
|
|
301
|
+
const initialConfig = getConfig();
|
|
302
|
+
// Start with no ISM
|
|
303
|
+
initialConfig.interchainSecurityModule = undefined;
|
|
304
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
305
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
306
|
+
// Verify ISM is unset
|
|
307
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
308
|
+
const readToken1 = await reader.read(deployedToken.deployed.address);
|
|
309
|
+
expect(readToken1.config.interchainSecurityModule).to.be.undefined;
|
|
310
|
+
// Update to set ISM
|
|
311
|
+
const ismWriter = ctx.ismArtifactManager.createWriter(AltVM.IsmType.TEST_ISM, ctx.aleoSigner);
|
|
312
|
+
const [deployedIsm] = await ismWriter.create({
|
|
313
|
+
config: { type: AltVM.IsmType.TEST_ISM },
|
|
314
|
+
});
|
|
315
|
+
const customIsmAddress = deployedIsm.deployed.address;
|
|
316
|
+
const updatedConfig = {
|
|
317
|
+
...deployedToken,
|
|
318
|
+
config: {
|
|
319
|
+
...deployedToken.config,
|
|
320
|
+
interchainSecurityModule: {
|
|
321
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
322
|
+
deployed: {
|
|
323
|
+
address: customIsmAddress,
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
const txs = await writer.update(updatedConfig);
|
|
329
|
+
expect(txs).to.be.an('array').with.length.greaterThan(0);
|
|
330
|
+
// Execute update
|
|
331
|
+
for (const tx of txs) {
|
|
332
|
+
await ctx.providerSdkSigner.sendAndConfirmTransaction(tx);
|
|
333
|
+
}
|
|
334
|
+
// Verify ISM is now set
|
|
335
|
+
const readToken2 = await reader.read(deployedToken.deployed.address);
|
|
336
|
+
assert(readToken2.config.interchainSecurityModule?.deployed.address, 'ISM address should exist');
|
|
337
|
+
expect(eqAddressAleo(readToken2.config.interchainSecurityModule.deployed.address, customIsmAddress)).to.be.true;
|
|
338
|
+
});
|
|
339
|
+
it('should change ISM when updated to different address', async () => {
|
|
340
|
+
const initialConfig = getConfig();
|
|
341
|
+
const ismWriter = ctx.ismArtifactManager.createWriter(AltVM.IsmType.TEST_ISM, ctx.aleoSigner);
|
|
342
|
+
const [firstIsm] = await ismWriter.create({
|
|
343
|
+
config: { type: AltVM.IsmType.TEST_ISM },
|
|
344
|
+
});
|
|
345
|
+
const firstIsmAddress = firstIsm.deployed.address;
|
|
346
|
+
const [secondIsm] = await ismWriter.create({
|
|
347
|
+
config: { type: AltVM.IsmType.TEST_ISM },
|
|
348
|
+
});
|
|
349
|
+
const secondIsmAddress = secondIsm.deployed.address;
|
|
350
|
+
// Create with first ISM
|
|
351
|
+
initialConfig.interchainSecurityModule = {
|
|
352
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
353
|
+
deployed: {
|
|
354
|
+
address: firstIsmAddress,
|
|
355
|
+
},
|
|
356
|
+
};
|
|
357
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
358
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
359
|
+
// Verify first ISM is set
|
|
360
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
361
|
+
const readToken1 = await reader.read(deployedToken.deployed.address);
|
|
362
|
+
assert(readToken1.config.interchainSecurityModule?.deployed.address, 'ISM address should exist');
|
|
363
|
+
expect(eqAddressAleo(readToken1.config.interchainSecurityModule.deployed.address, firstIsmAddress)).to.be.true;
|
|
364
|
+
// Update to second ISM
|
|
365
|
+
const updatedConfig = {
|
|
366
|
+
...deployedToken,
|
|
367
|
+
config: {
|
|
368
|
+
...deployedToken.config,
|
|
369
|
+
interchainSecurityModule: {
|
|
370
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
371
|
+
deployed: {
|
|
372
|
+
address: secondIsmAddress,
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
};
|
|
377
|
+
const txs = await writer.update(updatedConfig);
|
|
378
|
+
expect(txs).to.be.an('array').with.length.greaterThan(0);
|
|
379
|
+
// Execute update
|
|
380
|
+
for (const tx of txs) {
|
|
381
|
+
await ctx.providerSdkSigner.sendAndConfirmTransaction(tx);
|
|
382
|
+
}
|
|
383
|
+
// Verify ISM changed to second address
|
|
384
|
+
const readToken2 = await reader.read(deployedToken.deployed.address);
|
|
385
|
+
assert(readToken2.config.interchainSecurityModule?.deployed.address, 'ISM address should exist');
|
|
386
|
+
expect(eqAddressAleo(readToken2.config.interchainSecurityModule.deployed.address, secondIsmAddress)).to.be.true;
|
|
387
|
+
});
|
|
388
|
+
it('should not generate ISM update tx when ISM unchanged', async () => {
|
|
389
|
+
const initialConfig = getConfig();
|
|
390
|
+
const customIsmAddress = TEST_ALEO_BURN_ADDRESS;
|
|
391
|
+
// Create with ISM
|
|
392
|
+
initialConfig.interchainSecurityModule = {
|
|
393
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
394
|
+
deployed: {
|
|
395
|
+
address: customIsmAddress,
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
399
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
400
|
+
// Update with same ISM (no change)
|
|
401
|
+
const txs = await writer.update(deployedToken);
|
|
402
|
+
// Should have no transactions (ISM unchanged)
|
|
403
|
+
expect(txs).to.be.an('array').with.length(0);
|
|
404
|
+
});
|
|
405
|
+
it('should not generate ISM update tx when both undefined', async () => {
|
|
406
|
+
const initialConfig = getConfig();
|
|
407
|
+
// Create without ISM
|
|
408
|
+
initialConfig.interchainSecurityModule = undefined;
|
|
409
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
410
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
411
|
+
// Update with ISM still undefined (no change)
|
|
412
|
+
const txs = await writer.update(deployedToken);
|
|
413
|
+
// Should have no transactions (ISM still undefined)
|
|
414
|
+
expect(txs).to.be.an('array').with.length(0);
|
|
415
|
+
});
|
|
416
|
+
it('should not generate ISM update tx when current ism is undefined and the 0 address is provided in the config', async () => {
|
|
417
|
+
const initialConfig = getConfig();
|
|
418
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
419
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
420
|
+
const updatedConfig = {
|
|
421
|
+
...deployedToken,
|
|
422
|
+
config: {
|
|
423
|
+
...deployedToken.config,
|
|
424
|
+
interchainSecurityModule: {
|
|
425
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
426
|
+
deployed: {
|
|
427
|
+
address: '0x0000000000000000000000000000000000000000',
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
};
|
|
432
|
+
// Try to update with ISM still undefined (should not generate tx)
|
|
433
|
+
const txs = await writer.update(updatedConfig);
|
|
434
|
+
// Should generate 0 transactions (ISM unchanged)
|
|
435
|
+
expect(txs).to.be.an('array').with.length(0);
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
describe('Hook updates', function () {
|
|
439
|
+
it('should unset hook when changed from address to undefined', async () => {
|
|
440
|
+
const initialConfig = getConfig();
|
|
441
|
+
const hookWriter = ctx.hookArtifactManager.createWriter(AltVM.HookType.MERKLE_TREE, ctx.aleoSigner);
|
|
442
|
+
const [deployedHook] = await hookWriter.create({
|
|
443
|
+
config: { type: AltVM.HookType.MERKLE_TREE },
|
|
444
|
+
});
|
|
445
|
+
const customHookAddress = deployedHook.deployed.address;
|
|
446
|
+
// Create with hook set
|
|
447
|
+
initialConfig.hook = {
|
|
448
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
449
|
+
deployed: {
|
|
450
|
+
address: customHookAddress,
|
|
451
|
+
},
|
|
452
|
+
};
|
|
453
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
454
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
455
|
+
// Verify hook is set
|
|
456
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
457
|
+
const readToken1 = await reader.read(deployedToken.deployed.address);
|
|
458
|
+
assert(readToken1.config.hook?.deployed.address, 'Hook address should exist');
|
|
459
|
+
expect(eqAddressAleo(readToken1.config.hook.deployed.address, customHookAddress)).to.be.true;
|
|
460
|
+
// Update to clear hook (set to undefined)
|
|
461
|
+
const updatedConfig = {
|
|
462
|
+
...deployedToken,
|
|
463
|
+
config: {
|
|
464
|
+
...deployedToken.config,
|
|
465
|
+
hook: undefined,
|
|
466
|
+
},
|
|
467
|
+
};
|
|
468
|
+
const txs = await writer.update(updatedConfig);
|
|
469
|
+
expect(txs).to.be.an('array').with.length.greaterThan(0);
|
|
470
|
+
// Execute update
|
|
471
|
+
for (const tx of txs) {
|
|
472
|
+
await ctx.providerSdkSigner.sendAndConfirmTransaction(tx);
|
|
473
|
+
}
|
|
474
|
+
// Verify hook is now unset
|
|
475
|
+
const readToken2 = await reader.read(deployedToken.deployed.address);
|
|
476
|
+
expect(readToken2.config.hook).to.be.undefined;
|
|
477
|
+
});
|
|
478
|
+
it('should set hook when changed from undefined to address', async () => {
|
|
479
|
+
const initialConfig = getConfig();
|
|
480
|
+
// Start with no hook
|
|
481
|
+
initialConfig.hook = undefined;
|
|
482
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
483
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
484
|
+
// Verify hook is unset
|
|
485
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
486
|
+
const readToken1 = await reader.read(deployedToken.deployed.address);
|
|
487
|
+
expect(readToken1.config.hook).to.be.undefined;
|
|
488
|
+
// Update to set hook
|
|
489
|
+
const hookWriter = ctx.hookArtifactManager.createWriter(AltVM.HookType.MERKLE_TREE, ctx.aleoSigner);
|
|
490
|
+
const [deployedHook] = await hookWriter.create({
|
|
491
|
+
config: { type: AltVM.HookType.MERKLE_TREE },
|
|
492
|
+
});
|
|
493
|
+
const customHookAddress = deployedHook.deployed.address;
|
|
494
|
+
const updatedConfig = {
|
|
495
|
+
...deployedToken,
|
|
496
|
+
config: {
|
|
497
|
+
...deployedToken.config,
|
|
498
|
+
hook: {
|
|
499
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
500
|
+
deployed: {
|
|
501
|
+
address: customHookAddress,
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
},
|
|
505
|
+
};
|
|
506
|
+
const txs = await writer.update(updatedConfig);
|
|
507
|
+
expect(txs).to.be.an('array').with.length.greaterThan(0);
|
|
508
|
+
// Execute update
|
|
509
|
+
for (const tx of txs) {
|
|
510
|
+
await ctx.providerSdkSigner.sendAndConfirmTransaction(tx);
|
|
511
|
+
}
|
|
512
|
+
// Verify hook is now set
|
|
513
|
+
const readToken2 = await reader.read(deployedToken.deployed.address);
|
|
514
|
+
assert(readToken2.config.hook?.deployed.address, 'Hook address should exist');
|
|
515
|
+
expect(eqAddressAleo(readToken2.config.hook.deployed.address, customHookAddress)).to.be.true;
|
|
516
|
+
});
|
|
517
|
+
it('should change hook when updated to different address', async () => {
|
|
518
|
+
const initialConfig = getConfig();
|
|
519
|
+
const hookWriter = ctx.hookArtifactManager.createWriter(AltVM.HookType.MERKLE_TREE, ctx.aleoSigner);
|
|
520
|
+
const [firstHook] = await hookWriter.create({
|
|
521
|
+
config: { type: AltVM.HookType.MERKLE_TREE },
|
|
522
|
+
});
|
|
523
|
+
const firstHookAddress = firstHook.deployed.address;
|
|
524
|
+
const [secondHook] = await hookWriter.create({
|
|
525
|
+
config: { type: AltVM.HookType.MERKLE_TREE },
|
|
526
|
+
});
|
|
527
|
+
const secondHookAddress = secondHook.deployed.address;
|
|
528
|
+
// Create with first hook
|
|
529
|
+
initialConfig.hook = {
|
|
530
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
531
|
+
deployed: {
|
|
532
|
+
address: firstHookAddress,
|
|
533
|
+
},
|
|
534
|
+
};
|
|
535
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
536
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
537
|
+
// Verify first hook is set
|
|
538
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
539
|
+
const readToken1 = await reader.read(deployedToken.deployed.address);
|
|
540
|
+
assert(readToken1.config.hook?.deployed.address, 'Hook address should exist');
|
|
541
|
+
expect(eqAddressAleo(readToken1.config.hook.deployed.address, firstHookAddress)).to.be.true;
|
|
542
|
+
// Update to second hook
|
|
543
|
+
const updatedConfig = {
|
|
544
|
+
...deployedToken,
|
|
545
|
+
config: {
|
|
546
|
+
...deployedToken.config,
|
|
547
|
+
hook: {
|
|
548
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
549
|
+
deployed: {
|
|
550
|
+
address: secondHookAddress,
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
},
|
|
554
|
+
};
|
|
555
|
+
const txs = await writer.update(updatedConfig);
|
|
556
|
+
expect(txs).to.be.an('array').with.length.greaterThan(0);
|
|
557
|
+
// Execute update
|
|
558
|
+
for (const tx of txs) {
|
|
559
|
+
await ctx.providerSdkSigner.sendAndConfirmTransaction(tx);
|
|
560
|
+
}
|
|
561
|
+
// Verify hook changed to second address
|
|
562
|
+
const readToken2 = await reader.read(deployedToken.deployed.address);
|
|
563
|
+
assert(readToken2.config.hook?.deployed.address, 'Hook address should exist');
|
|
564
|
+
expect(eqAddressAleo(readToken2.config.hook.deployed.address, secondHookAddress)).to.be.true;
|
|
565
|
+
});
|
|
566
|
+
it('should not generate hook update tx when hook unchanged', async () => {
|
|
567
|
+
const initialConfig = getConfig();
|
|
568
|
+
const customHookAddress = TEST_ALEO_BURN_ADDRESS;
|
|
569
|
+
// Create with hook
|
|
570
|
+
initialConfig.hook = {
|
|
571
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
572
|
+
deployed: {
|
|
573
|
+
address: customHookAddress,
|
|
574
|
+
},
|
|
575
|
+
};
|
|
576
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
577
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
578
|
+
// Update with same hook (no change)
|
|
579
|
+
const txs = await writer.update(deployedToken);
|
|
580
|
+
// Should have no transactions (hook unchanged)
|
|
581
|
+
expect(txs).to.be.an('array').with.length(0);
|
|
582
|
+
});
|
|
583
|
+
it('should not generate hook update tx when both undefined', async () => {
|
|
584
|
+
const initialConfig = getConfig();
|
|
585
|
+
// Create without hook
|
|
586
|
+
initialConfig.hook = undefined;
|
|
587
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
588
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
589
|
+
// Update with hook still undefined (no change)
|
|
590
|
+
const txs = await writer.update(deployedToken);
|
|
591
|
+
// Should have no transactions (hook still undefined)
|
|
592
|
+
expect(txs).to.be.an('array').with.length(0);
|
|
593
|
+
});
|
|
594
|
+
it('should unset hook when changed to zero address', async () => {
|
|
595
|
+
const initialConfig = getConfig();
|
|
596
|
+
// Create a real hook to start with
|
|
597
|
+
const hookWriter = ctx.hookArtifactManager.createWriter(AltVM.HookType.MERKLE_TREE, ctx.aleoSigner);
|
|
598
|
+
const [deployedHook] = await hookWriter.create({
|
|
599
|
+
config: { type: AltVM.HookType.MERKLE_TREE },
|
|
600
|
+
});
|
|
601
|
+
const customHookAddress = deployedHook.deployed.address;
|
|
602
|
+
// Create with hook set
|
|
603
|
+
initialConfig.hook = {
|
|
604
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
605
|
+
deployed: {
|
|
606
|
+
address: customHookAddress,
|
|
607
|
+
},
|
|
608
|
+
};
|
|
609
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
610
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
611
|
+
// Verify hook is set
|
|
612
|
+
const reader = ctx.artifactManager.createReader(type);
|
|
613
|
+
const readToken1 = await reader.read(deployedToken.deployed.address);
|
|
614
|
+
assert(readToken1.config.hook?.deployed.address, 'Hook address should exist');
|
|
615
|
+
expect(eqAddressAleo(readToken1.config.hook.deployed.address, customHookAddress)).to.be.true;
|
|
616
|
+
// Update to zero address (should unset hook)
|
|
617
|
+
const zeroAddress = TEST_ALEO_BURN_ADDRESS;
|
|
618
|
+
const updatedConfig = {
|
|
619
|
+
...deployedToken,
|
|
620
|
+
config: {
|
|
621
|
+
...deployedToken.config,
|
|
622
|
+
hook: {
|
|
623
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
624
|
+
deployed: {
|
|
625
|
+
address: zeroAddress,
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
},
|
|
629
|
+
};
|
|
630
|
+
const txs = await writer.update(updatedConfig);
|
|
631
|
+
expect(txs).to.be.an('array').with.length.greaterThan(0);
|
|
632
|
+
// Execute update
|
|
633
|
+
for (const tx of txs) {
|
|
634
|
+
await ctx.providerSdkSigner.sendAndConfirmTransaction(tx);
|
|
635
|
+
}
|
|
636
|
+
// Verify hook is now unset (zero address treated as unset)
|
|
637
|
+
const readToken2 = await reader.read(deployedToken.deployed.address);
|
|
638
|
+
expect(readToken2.config.hook).to.be.undefined;
|
|
639
|
+
});
|
|
640
|
+
it('should not generate hook update tx when current hook is undefined and the 0 address is provided in the config', async () => {
|
|
641
|
+
const initialConfig = getConfig();
|
|
642
|
+
const writer = ctx.artifactManager.createWriter(type, ctx.aleoSigner);
|
|
643
|
+
const deployedToken = await getDeployedToken(initialConfig);
|
|
644
|
+
const updatedConfig = {
|
|
645
|
+
...deployedToken,
|
|
646
|
+
config: {
|
|
647
|
+
...deployedToken.config,
|
|
648
|
+
hook: {
|
|
649
|
+
artifactState: ArtifactState.UNDERIVED,
|
|
650
|
+
deployed: {
|
|
651
|
+
address: '0x0000000000000000000000000000000000000000',
|
|
652
|
+
},
|
|
653
|
+
},
|
|
654
|
+
},
|
|
655
|
+
};
|
|
656
|
+
// Try to update with Hook still undefined (should not generate tx)
|
|
657
|
+
const txs = await writer.update(updatedConfig);
|
|
658
|
+
// Should generate 0 transactions (Hook unchanged)
|
|
659
|
+
expect(txs).to.be.an('array').with.length(0);
|
|
660
|
+
});
|
|
661
|
+
});
|
|
662
|
+
it(`should detect and read ${testCase.name} token via readWarpToken`, async () => {
|
|
663
|
+
const config = getConfig();
|
|
664
|
+
const deployedToken = await getDeployedToken(config);
|
|
665
|
+
// Read via generic readWarpToken (without knowing the type)
|
|
666
|
+
const readToken = await ctx.artifactManager.readWarpToken(deployedToken.deployed.address);
|
|
667
|
+
expect(readToken.artifactState).to.equal(ArtifactState.DEPLOYED);
|
|
668
|
+
expect(readToken.config.type).to.equal(type);
|
|
669
|
+
expect(readToken.deployed.address).to.equal(deployedToken.deployed.address);
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
//# sourceMappingURL=warp-artifact-test-suite.js.map
|