@aztec/protocol-contracts 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9
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/artifacts/AuthRegistry.json +1625 -1630
- package/artifacts/ContractClassRegistry.json +897 -7230
- package/artifacts/ContractInstanceRegistry.json +1105 -1772
- package/artifacts/FeeJuice.json +2884 -1598
- package/artifacts/MultiCallEntrypoint.json +1190 -1129
- package/artifacts/PublicChecks.json +988 -0
- package/dest/auth-registry/index.d.ts +1 -1
- package/dest/auth-registry/index.d.ts.map +1 -1
- package/dest/auth-registry/index.js +3 -3
- package/dest/auth-registry/lazy.d.ts +1 -1
- package/dest/auth-registry/lazy.js +5 -5
- package/dest/class-registry/contract_class_published_event.d.ts +3 -2
- package/dest/class-registry/contract_class_published_event.d.ts.map +1 -1
- package/dest/class-registry/contract_class_published_event.js +4 -0
- package/dest/class-registry/index.d.ts +1 -1
- package/dest/class-registry/index.d.ts.map +1 -1
- package/dest/class-registry/index.js +3 -3
- package/dest/class-registry/lazy.d.ts +1 -1
- package/dest/class-registry/lazy.js +5 -5
- package/dest/class-registry/private_function_broadcasted_event.d.ts +2 -2
- package/dest/class-registry/private_function_broadcasted_event.d.ts.map +1 -1
- package/dest/class-registry/utility_function_broadcasted_event.d.ts +2 -2
- package/dest/class-registry/utility_function_broadcasted_event.d.ts.map +1 -1
- package/dest/class-registry/utility_function_broadcasted_event.js +1 -1
- package/dest/fee-juice/index.d.ts +2 -2
- package/dest/fee-juice/index.d.ts.map +1 -1
- package/dest/fee-juice/index.js +3 -3
- package/dest/fee-juice/lazy.d.ts +1 -1
- package/dest/fee-juice/lazy.js +5 -5
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/instance-registry/contract_instance_published_event.d.ts +3 -2
- package/dest/instance-registry/contract_instance_published_event.d.ts.map +1 -1
- package/dest/instance-registry/contract_instance_published_event.js +4 -1
- package/dest/instance-registry/contract_instance_updated_event.d.ts +2 -2
- package/dest/instance-registry/contract_instance_updated_event.d.ts.map +1 -1
- package/dest/instance-registry/contract_instance_updated_event.js +5 -7
- package/dest/instance-registry/index.d.ts +1 -1
- package/dest/instance-registry/index.d.ts.map +1 -1
- package/dest/instance-registry/index.js +3 -3
- package/dest/instance-registry/lazy.d.ts +1 -1
- package/dest/instance-registry/lazy.js +5 -5
- package/dest/make_protocol_contract.d.ts +4 -4
- package/dest/make_protocol_contract.d.ts.map +1 -1
- package/dest/make_protocol_contract.js +28 -14
- package/dest/multi-call-entrypoint/index.d.ts +1 -1
- package/dest/multi-call-entrypoint/index.d.ts.map +1 -1
- package/dest/multi-call-entrypoint/index.js +3 -3
- package/dest/multi-call-entrypoint/lazy.d.ts +1 -1
- package/dest/multi-call-entrypoint/lazy.js +5 -5
- package/dest/protocol_contract.d.ts +1 -1
- package/dest/protocol_contract_data.d.ts +25 -11
- package/dest/protocol_contract_data.d.ts.map +1 -1
- package/dest/protocol_contract_data.js +113 -13
- package/dest/provider/bundle.d.ts +1 -1
- package/dest/provider/bundle.d.ts.map +1 -1
- package/dest/provider/bundle.js +3 -3
- package/dest/provider/lazy.d.ts +1 -1
- package/dest/provider/lazy.d.ts.map +1 -1
- package/dest/provider/lazy.js +3 -3
- package/dest/provider/protocol_contracts_provider.d.ts +1 -1
- package/dest/public-checks/index.d.ts +5 -0
- package/dest/public-checks/index.d.ts.map +1 -0
- package/dest/public-checks/index.js +13 -0
- package/dest/public-checks/lazy.d.ts +6 -0
- package/dest/public-checks/lazy.d.ts.map +1 -0
- package/dest/public-checks/lazy.js +23 -0
- package/dest/scripts/generate_data.js +88 -37
- package/dest/tests/fixtures.d.ts +1 -1
- package/package.json +9 -8
- package/src/auth-registry/index.ts +3 -3
- package/src/auth-registry/lazy.ts +5 -5
- package/src/class-registry/contract_class_published_event.ts +8 -1
- package/src/class-registry/index.ts +3 -3
- package/src/class-registry/lazy.ts +5 -5
- package/src/class-registry/private_function_broadcasted_event.ts +1 -1
- package/src/class-registry/utility_function_broadcasted_event.ts +1 -1
- package/src/fee-juice/index.ts +4 -4
- package/src/fee-juice/lazy.ts +5 -5
- package/src/index.ts +0 -1
- package/src/instance-registry/contract_instance_published_event.ts +7 -1
- package/src/instance-registry/contract_instance_updated_event.ts +6 -8
- package/src/instance-registry/index.ts +3 -3
- package/src/instance-registry/lazy.ts +5 -5
- package/src/make_protocol_contract.ts +37 -15
- package/src/multi-call-entrypoint/index.ts +3 -3
- package/src/multi-call-entrypoint/lazy.ts +5 -5
- package/src/protocol_contract_data.ts +91 -13
- package/src/provider/bundle.ts +3 -3
- package/src/provider/lazy.ts +3 -3
- package/src/{router → public-checks}/index.ts +5 -5
- package/src/public-checks/lazy.ts +29 -0
- package/artifacts/Router.json +0 -4629
- package/dest/build_protocol_contract_tree.d.ts +0 -10
- package/dest/build_protocol_contract_tree.d.ts.map +0 -1
- package/dest/build_protocol_contract_tree.js +0 -20
- package/dest/protocol_contract_tree.d.ts +0 -7
- package/dest/protocol_contract_tree.d.ts.map +0 -1
- package/dest/protocol_contract_tree.js +0 -34
- package/dest/router/index.d.ts +0 -5
- package/dest/router/index.d.ts.map +0 -1
- package/dest/router/index.js +0 -13
- package/dest/router/lazy.d.ts +0 -6
- package/dest/router/lazy.d.ts.map +0 -1
- package/dest/router/lazy.js +0 -23
- package/src/build_protocol_contract_tree.ts +0 -29
- package/src/protocol_contract_tree.ts +0 -44
- package/src/router/lazy.ts +0 -29
- /package/artifacts/{Router.d.json.ts → PublicChecks.d.json.ts} +0 -0
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PROTOCOL_CONTRACT_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import { type IndexedMerkleTree } from '@aztec/foundation/trees';
|
|
4
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
|
|
6
|
-
export declare function buildProtocolContractTree(contracts: {
|
|
7
|
-
address: AztecAddress;
|
|
8
|
-
leaf: Fr;
|
|
9
|
-
}[]): Promise<IndexedMerkleTree<ProtocolContractLeafPreimage, typeof PROTOCOL_CONTRACT_TREE_HEIGHT>>;
|
|
10
|
-
//# sourceMappingURL=build_protocol_contract_tree.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build_protocol_contract_tree.d.ts","sourceRoot":"","sources":["../src/build_protocol_contract_tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAEzF,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,KAAK,iBAAiB,EAA+B,MAAM,yBAAyB,CAAC;AAC9F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEnE,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,EAAE,CAAA;CAAE,EAAE,GAC/C,OAAO,CAAC,iBAAiB,CAAC,4BAA4B,EAAE,OAAO,6BAA6B,CAAC,CAAC,CAmBhG"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { MAX_PROTOCOL_CONTRACTS, PROTOCOL_CONTRACT_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
3
|
-
import { IndexedMerkleTreeCalculator } from '@aztec/foundation/trees';
|
|
4
|
-
import { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
|
|
5
|
-
export async function buildProtocolContractTree(contracts) {
|
|
6
|
-
const hasher = {
|
|
7
|
-
hash: async (l, r)=>(await poseidon2Hash([
|
|
8
|
-
l,
|
|
9
|
-
r
|
|
10
|
-
])).toBuffer(),
|
|
11
|
-
hashInputs: async (i)=>(await poseidon2Hash(i)).toBuffer()
|
|
12
|
-
};
|
|
13
|
-
const calculator = await IndexedMerkleTreeCalculator.create(PROTOCOL_CONTRACT_TREE_HEIGHT, hasher, ProtocolContractLeafPreimage);
|
|
14
|
-
const leaves = new Array(MAX_PROTOCOL_CONTRACTS).fill(Buffer.alloc(32));
|
|
15
|
-
for (const contract of contracts){
|
|
16
|
-
const index = contract.address.toField().toNumber();
|
|
17
|
-
leaves[index] = contract.leaf.toBuffer();
|
|
18
|
-
}
|
|
19
|
-
return calculator.computeTree(leaves);
|
|
20
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
-
import type { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
|
|
3
|
-
export declare function getProtocolContractLeafAndMembershipWitness(contractAddress: AztecAddress, computedAddress: AztecAddress): Promise<{
|
|
4
|
-
lowLeaf: ProtocolContractLeafPreimage;
|
|
5
|
-
witness: import("@aztec/foundation/trees").MembershipWitness<3>;
|
|
6
|
-
}>;
|
|
7
|
-
//# sourceMappingURL=protocol_contract_tree.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol_contract_tree.d.ts","sourceRoot":"","sources":["../src/protocol_contract_tree.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAsBxE,wBAAsB,2CAA2C,CAC/D,eAAe,EAAE,YAAY,EAC7B,eAAe,EAAE,YAAY;;;GAe9B"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
2
|
-
import { buildProtocolContractTree } from './build_protocol_contract_tree.js';
|
|
3
|
-
import { isProtocolContract } from './protocol_contract.js';
|
|
4
|
-
import { ProtocolContractAddress, ProtocolContractLeaves, protocolContractNames } from './protocol_contract_data.js';
|
|
5
|
-
let protocolContractTree;
|
|
6
|
-
async function getTree() {
|
|
7
|
-
if (!protocolContractTree) {
|
|
8
|
-
const leaves = protocolContractNames.map((name)=>({
|
|
9
|
-
address: ProtocolContractAddress[name],
|
|
10
|
-
leaf: ProtocolContractLeaves[name]
|
|
11
|
-
}));
|
|
12
|
-
protocolContractTree = await buildProtocolContractTree(leaves);
|
|
13
|
-
}
|
|
14
|
-
return protocolContractTree;
|
|
15
|
-
}
|
|
16
|
-
// Computed address can be different from contract address due to upgrades
|
|
17
|
-
export async function getProtocolContractLeafAndMembershipWitness(contractAddress, computedAddress) {
|
|
18
|
-
const tree = await getTree();
|
|
19
|
-
let lowLeaf;
|
|
20
|
-
let witness;
|
|
21
|
-
if (isProtocolContract(contractAddress)) {
|
|
22
|
-
const index = contractAddress.toField().toNumber();
|
|
23
|
-
lowLeaf = tree.leafPreimages[index];
|
|
24
|
-
witness = tree.getMembershipWitness(index);
|
|
25
|
-
} else {
|
|
26
|
-
lowLeaf = tree.getLowLeaf(computedAddress.toBigInt());
|
|
27
|
-
const hashed = (await poseidon2Hash(lowLeaf.toHashInputs())).toBuffer();
|
|
28
|
-
witness = tree.getMembershipWitness(hashed);
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
lowLeaf,
|
|
32
|
-
witness
|
|
33
|
-
};
|
|
34
|
-
}
|
package/dest/router/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ProtocolContract } from '../protocol_contract.js';
|
|
2
|
-
export declare const RouterArtifact: import("@aztec/stdlib/abi").ContractArtifact;
|
|
3
|
-
/** Returns the canonical deployment of the contract. */
|
|
4
|
-
export declare function getCanonicalRouter(): Promise<ProtocolContract>;
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,eAAO,MAAM,cAAc,8CAA2D,CAAC;AAIvF,wDAAwD;AACxD,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAKpE"}
|
package/dest/router/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
import RouterJson from '../../artifacts/Router.json' with {
|
|
3
|
-
type: 'json'
|
|
4
|
-
};
|
|
5
|
-
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
6
|
-
export const RouterArtifact = loadContractArtifact(RouterJson);
|
|
7
|
-
let protocolContract;
|
|
8
|
-
/** Returns the canonical deployment of the contract. */ export async function getCanonicalRouter() {
|
|
9
|
-
if (!protocolContract) {
|
|
10
|
-
protocolContract = await makeProtocolContract('Router', RouterArtifact);
|
|
11
|
-
}
|
|
12
|
-
return protocolContract;
|
|
13
|
-
}
|
package/dest/router/lazy.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
import type { ProtocolContract } from '../protocol_contract.js';
|
|
3
|
-
export declare function getRouterArtifact(): Promise<ContractArtifact>;
|
|
4
|
-
/** Returns the canonical deployment of the auth registry. */
|
|
5
|
-
export declare function getCanonicalRouter(): Promise<ProtocolContract>;
|
|
6
|
-
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/router/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAGhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAWnE;AAED,6DAA6D;AAC7D,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAMpE"}
|
package/dest/router/lazy.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
3
|
-
let protocolContract;
|
|
4
|
-
let protocolContractArtifact;
|
|
5
|
-
export async function getRouterArtifact() {
|
|
6
|
-
if (!protocolContractArtifact) {
|
|
7
|
-
// Cannot assert this import as it's incompatible with browsers
|
|
8
|
-
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
9
|
-
// Use the new "with" syntax once supported by firefox
|
|
10
|
-
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
11
|
-
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
12
|
-
const { default: routerJson } = await import('../../artifacts/Router.json');
|
|
13
|
-
protocolContractArtifact = loadContractArtifact(routerJson);
|
|
14
|
-
}
|
|
15
|
-
return protocolContractArtifact;
|
|
16
|
-
}
|
|
17
|
-
/** Returns the canonical deployment of the auth registry. */ export async function getCanonicalRouter() {
|
|
18
|
-
if (!protocolContract) {
|
|
19
|
-
const routerArtifact = await getRouterArtifact();
|
|
20
|
-
protocolContract = await makeProtocolContract('Router', routerArtifact);
|
|
21
|
-
}
|
|
22
|
-
return protocolContract;
|
|
23
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { MAX_PROTOCOL_CONTRACTS, PROTOCOL_CONTRACT_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
3
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
4
|
-
import { type IndexedMerkleTree, IndexedMerkleTreeCalculator } from '@aztec/foundation/trees';
|
|
5
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
|
|
7
|
-
|
|
8
|
-
export async function buildProtocolContractTree(
|
|
9
|
-
contracts: { address: AztecAddress; leaf: Fr }[],
|
|
10
|
-
): Promise<IndexedMerkleTree<ProtocolContractLeafPreimage, typeof PROTOCOL_CONTRACT_TREE_HEIGHT>> {
|
|
11
|
-
const hasher = {
|
|
12
|
-
hash: async (l: Buffer, r: Buffer) => (await poseidon2Hash([l, r])).toBuffer() as Buffer<ArrayBuffer>,
|
|
13
|
-
hashInputs: async (i: Buffer[]) => (await poseidon2Hash(i)).toBuffer() as Buffer<ArrayBuffer>,
|
|
14
|
-
};
|
|
15
|
-
const calculator = await IndexedMerkleTreeCalculator.create(
|
|
16
|
-
PROTOCOL_CONTRACT_TREE_HEIGHT,
|
|
17
|
-
hasher,
|
|
18
|
-
ProtocolContractLeafPreimage,
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const leaves = new Array(MAX_PROTOCOL_CONTRACTS).fill(Buffer.alloc(32));
|
|
22
|
-
|
|
23
|
-
for (const contract of contracts) {
|
|
24
|
-
const index = contract.address.toField().toNumber();
|
|
25
|
-
leaves[index] = contract.leaf.toBuffer();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return calculator.computeTree(leaves);
|
|
29
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { PROTOCOL_CONTRACT_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
3
|
-
import type { IndexedMerkleTree } from '@aztec/foundation/trees';
|
|
4
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
|
|
6
|
-
|
|
7
|
-
import { buildProtocolContractTree } from './build_protocol_contract_tree.js';
|
|
8
|
-
import { isProtocolContract } from './protocol_contract.js';
|
|
9
|
-
import { ProtocolContractAddress, ProtocolContractLeaves, protocolContractNames } from './protocol_contract_data.js';
|
|
10
|
-
|
|
11
|
-
let protocolContractTree:
|
|
12
|
-
| IndexedMerkleTree<ProtocolContractLeafPreimage, typeof PROTOCOL_CONTRACT_TREE_HEIGHT>
|
|
13
|
-
| undefined;
|
|
14
|
-
|
|
15
|
-
async function getTree() {
|
|
16
|
-
if (!protocolContractTree) {
|
|
17
|
-
const leaves = protocolContractNames.map(name => ({
|
|
18
|
-
address: ProtocolContractAddress[name],
|
|
19
|
-
leaf: ProtocolContractLeaves[name],
|
|
20
|
-
}));
|
|
21
|
-
protocolContractTree = await buildProtocolContractTree(leaves);
|
|
22
|
-
}
|
|
23
|
-
return protocolContractTree;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Computed address can be different from contract address due to upgrades
|
|
27
|
-
export async function getProtocolContractLeafAndMembershipWitness(
|
|
28
|
-
contractAddress: AztecAddress,
|
|
29
|
-
computedAddress: AztecAddress,
|
|
30
|
-
) {
|
|
31
|
-
const tree = await getTree();
|
|
32
|
-
let lowLeaf;
|
|
33
|
-
let witness;
|
|
34
|
-
if (isProtocolContract(contractAddress)) {
|
|
35
|
-
const index = contractAddress.toField().toNumber();
|
|
36
|
-
lowLeaf = tree.leafPreimages[index];
|
|
37
|
-
witness = tree.getMembershipWitness(index);
|
|
38
|
-
} else {
|
|
39
|
-
lowLeaf = tree.getLowLeaf(computedAddress.toBigInt());
|
|
40
|
-
const hashed = (await poseidon2Hash(lowLeaf.toHashInputs())).toBuffer();
|
|
41
|
-
witness = tree.getMembershipWitness(hashed);
|
|
42
|
-
}
|
|
43
|
-
return { lowLeaf, witness };
|
|
44
|
-
}
|
package/src/router/lazy.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type ContractArtifact, loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
|
|
3
|
-
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
4
|
-
import type { ProtocolContract } from '../protocol_contract.js';
|
|
5
|
-
|
|
6
|
-
let protocolContract: ProtocolContract;
|
|
7
|
-
let protocolContractArtifact: ContractArtifact;
|
|
8
|
-
|
|
9
|
-
export async function getRouterArtifact(): Promise<ContractArtifact> {
|
|
10
|
-
if (!protocolContractArtifact) {
|
|
11
|
-
// Cannot assert this import as it's incompatible with browsers
|
|
12
|
-
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
13
|
-
// Use the new "with" syntax once supported by firefox
|
|
14
|
-
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
15
|
-
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
16
|
-
const { default: routerJson } = await import('../../artifacts/Router.json');
|
|
17
|
-
protocolContractArtifact = loadContractArtifact(routerJson);
|
|
18
|
-
}
|
|
19
|
-
return protocolContractArtifact;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Returns the canonical deployment of the auth registry. */
|
|
23
|
-
export async function getCanonicalRouter(): Promise<ProtocolContract> {
|
|
24
|
-
if (!protocolContract) {
|
|
25
|
-
const routerArtifact = await getRouterArtifact();
|
|
26
|
-
protocolContract = await makeProtocolContract('Router', routerArtifact);
|
|
27
|
-
}
|
|
28
|
-
return protocolContract;
|
|
29
|
-
}
|
|
File without changes
|