@hyperlane-xyz/sdk 12.0.0 → 12.1.0-cli-bundle.0
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/dist/deploy/proxy.d.ts +7 -4
- package/dist/deploy/proxy.d.ts.map +1 -1
- package/dist/deploy/proxy.js.map +1 -1
- package/dist/deploy/proxyFactoryUtils.d.ts +7 -0
- package/dist/deploy/proxyFactoryUtils.d.ts.map +1 -0
- package/dist/deploy/proxyFactoryUtils.js +12 -0
- package/dist/deploy/proxyFactoryUtils.js.map +1 -0
- package/dist/hook/types.d.ts +1 -0
- package/dist/hook/types.d.ts.map +1 -1
- package/dist/hook/types.js +14 -0
- package/dist/hook/types.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/ism/types.d.ts +5 -0
- package/dist/ism/types.d.ts.map +1 -1
- package/dist/ism/types.js +12 -0
- package/dist/ism/types.js.map +1 -1
- package/dist/ism/utils.d.ts +21 -1
- package/dist/ism/utils.d.ts.map +1 -1
- package/dist/ism/utils.js +25 -1
- package/dist/ism/utils.js.map +1 -1
- package/dist/metadata/agentConfig.d.ts +290 -245
- package/dist/metadata/agentConfig.d.ts.map +1 -1
- package/dist/metadata/agentConfig.js +26 -0
- package/dist/metadata/agentConfig.js.map +1 -1
- package/dist/metadata/chainMetadataTypes.d.ts +1 -0
- package/dist/metadata/chainMetadataTypes.d.ts.map +1 -1
- package/dist/metadata/chainMetadataTypes.js +1 -0
- package/dist/metadata/chainMetadataTypes.js.map +1 -1
- package/dist/router/HyperlaneRouterChecker.d.ts.map +1 -1
- package/dist/router/HyperlaneRouterChecker.js +19 -0
- package/dist/router/HyperlaneRouterChecker.js.map +1 -1
- package/dist/router/ProxiedRouterChecker.d.ts.map +1 -1
- package/dist/router/ProxiedRouterChecker.js +7 -0
- package/dist/router/ProxiedRouterChecker.js.map +1 -1
- package/dist/router/types.d.ts +7 -0
- package/dist/router/types.d.ts.map +1 -1
- package/dist/router/types.js +1 -0
- package/dist/router/types.js.map +1 -1
- package/dist/utils/zksync.d.ts +8 -0
- package/dist/utils/zksync.d.ts.map +1 -0
- package/dist/utils/zksync.js +24 -0
- package/dist/utils/zksync.js.map +1 -0
- package/dist/zksync/ZKSyncDeployer.d.ts +59 -0
- package/dist/zksync/ZKSyncDeployer.d.ts.map +1 -0
- package/dist/zksync/ZKSyncDeployer.js +123 -0
- package/dist/zksync/ZKSyncDeployer.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { utils } from 'ethers';
|
|
2
|
+
import { ContractFactory, } from 'zksync-ethers';
|
|
3
|
+
import { assert } from '@hyperlane-xyz/utils';
|
|
4
|
+
import { defaultZKProviderBuilder } from '../providers/providerBuilders.js';
|
|
5
|
+
import { getZKSyncArtifactByContractName } from '../utils/zksync.js';
|
|
6
|
+
/**
|
|
7
|
+
* Class for deploying contracts to the ZKSync network.
|
|
8
|
+
*/
|
|
9
|
+
export class ZKSyncDeployer {
|
|
10
|
+
zkWallet;
|
|
11
|
+
deploymentType;
|
|
12
|
+
constructor(zkWallet, deploymentType) {
|
|
13
|
+
this.deploymentType = deploymentType;
|
|
14
|
+
this.zkWallet = zkWallet.connect(zkWallet.provider ??
|
|
15
|
+
defaultZKProviderBuilder([{ http: 'http://127.0.0.1:8011' }], 260));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Loads and validates a ZKSync contract artifact by name
|
|
19
|
+
* @param contractTitle - Contract name or qualified name (sourceName:contractName)
|
|
20
|
+
*
|
|
21
|
+
* @returns The ZKSync artifact
|
|
22
|
+
*/
|
|
23
|
+
async loadArtifact(contractTitle) {
|
|
24
|
+
const artifact = await getZKSyncArtifactByContractName(contractTitle);
|
|
25
|
+
assert(artifact, `No ZKSync artifact for contract ${contractTitle} found!`);
|
|
26
|
+
return artifact;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Estimates the price of calling a deploy transaction in ETH.
|
|
30
|
+
*
|
|
31
|
+
* @param artifact The previously loaded artifact object.
|
|
32
|
+
* @param constructorArguments List of arguments to be passed to the contract constructor.
|
|
33
|
+
*
|
|
34
|
+
* @returns Calculated fee in ETH wei
|
|
35
|
+
*/
|
|
36
|
+
async estimateDeployFee(artifact, constructorArguments) {
|
|
37
|
+
const gas = await this.estimateDeployGas(artifact, constructorArguments);
|
|
38
|
+
const gasPrice = await this.zkWallet.provider.getGasPrice();
|
|
39
|
+
return gas.mul(gasPrice);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Estimates the amount of gas needed to execute a deploy transaction.
|
|
43
|
+
*
|
|
44
|
+
* @param artifact The previously loaded artifact object.
|
|
45
|
+
* @param constructorArguments List of arguments to be passed to the contract constructor.
|
|
46
|
+
*
|
|
47
|
+
* @returns Calculated amount of gas.
|
|
48
|
+
*/
|
|
49
|
+
async estimateDeployGas(artifact, constructorArguments) {
|
|
50
|
+
const factoryDeps = await this.extractFactoryDeps(artifact);
|
|
51
|
+
const factory = new ContractFactory(artifact.abi, artifact.bytecode, this.zkWallet, this.deploymentType);
|
|
52
|
+
// Encode deploy transaction so it can be estimated.
|
|
53
|
+
const deployTx = factory.getDeployTransaction(...constructorArguments, {
|
|
54
|
+
customData: {
|
|
55
|
+
factoryDeps,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
deployTx.from = this.zkWallet.address;
|
|
59
|
+
return this.zkWallet.provider.estimateGas(deployTx);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Sends a deploy transaction to the zkSync network.
|
|
63
|
+
* For now, it will use defaults for the transaction parameters:
|
|
64
|
+
* - fee amount is requested automatically from the zkSync server.
|
|
65
|
+
*
|
|
66
|
+
* @param artifact The previously loaded artifact object.
|
|
67
|
+
* @param constructorArguments List of arguments to be passed to the contract constructor.
|
|
68
|
+
* @param overrides Optional object with additional deploy transaction parameters.
|
|
69
|
+
* @param additionalFactoryDeps Additional contract bytecodes to be added to the factory dependencies list.
|
|
70
|
+
*
|
|
71
|
+
* @returns A contract object.
|
|
72
|
+
*/
|
|
73
|
+
async deploy(artifact, constructorArguments = [], overrides, additionalFactoryDeps) {
|
|
74
|
+
const baseDeps = await this.extractFactoryDeps(artifact);
|
|
75
|
+
const additionalDeps = additionalFactoryDeps
|
|
76
|
+
? additionalFactoryDeps.map((val) => utils.hexlify(val))
|
|
77
|
+
: [];
|
|
78
|
+
const factoryDeps = [...baseDeps, ...additionalDeps];
|
|
79
|
+
const factory = new ContractFactory(artifact.abi, artifact.bytecode, this.zkWallet, this.deploymentType);
|
|
80
|
+
const { customData, ..._overrides } = overrides ?? {};
|
|
81
|
+
// Encode and send the deploy transaction providing factory dependencies.
|
|
82
|
+
const contract = await factory.deploy(...constructorArguments, {
|
|
83
|
+
..._overrides,
|
|
84
|
+
customData: {
|
|
85
|
+
...customData,
|
|
86
|
+
factoryDeps,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
await contract.deployed();
|
|
90
|
+
return contract;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Extracts factory dependencies from the artifact.
|
|
94
|
+
*
|
|
95
|
+
* @param artifact Artifact to extract dependencies from
|
|
96
|
+
*
|
|
97
|
+
* @returns Factory dependencies in the format expected by SDK.
|
|
98
|
+
*/
|
|
99
|
+
async extractFactoryDeps(artifact) {
|
|
100
|
+
const visited = new Set();
|
|
101
|
+
visited.add(`${artifact.sourceName}:${artifact.contractName}`);
|
|
102
|
+
return this.extractFactoryDepsRecursive(artifact, visited);
|
|
103
|
+
}
|
|
104
|
+
async extractFactoryDepsRecursive(artifact, visited) {
|
|
105
|
+
// Load all the dependency bytecodes.
|
|
106
|
+
// We transform it into an array of bytecodes.
|
|
107
|
+
const factoryDeps = [];
|
|
108
|
+
for (const dependencyHash in artifact.factoryDeps) {
|
|
109
|
+
if (Object.prototype.hasOwnProperty.call(artifact.factoryDeps, dependencyHash)) {
|
|
110
|
+
const dependencyContract = artifact.factoryDeps[dependencyHash];
|
|
111
|
+
if (!visited.has(dependencyContract)) {
|
|
112
|
+
const dependencyArtifact = await this.loadArtifact(dependencyContract);
|
|
113
|
+
factoryDeps.push(dependencyArtifact.bytecode);
|
|
114
|
+
visited.add(dependencyContract);
|
|
115
|
+
const transitiveDeps = await this.extractFactoryDepsRecursive(dependencyArtifact, visited);
|
|
116
|
+
factoryDeps.push(...transitiveDeps);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return factoryDeps;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=ZKSyncDeployer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZKSyncDeployer.js","sourceRoot":"","sources":["../../src/zksync/ZKSyncDeployer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAEL,eAAe,GAGhB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AAErE;;GAEG;AACH,MAAM,OAAO,cAAc;IAClB,QAAQ,CAAS;IACjB,cAAc,CAA8B;IAEnD,YAAY,QAAgB,EAAE,cAA2C;QACvE,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QAErC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAC9B,QAAQ,CAAC,QAAQ;YACf,wBAAwB,CAAC,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC,EAAE,GAAG,CAAC,CACrE,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,YAAY,CAAC,aAAqB;QAC9C,MAAM,QAAQ,GA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AClD,IACE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAClC,QAAQ,CAAC,WAAW,EACpB,cAAc,CACf,EACD,CAAC;gBACD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;gBAChE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,CAAC;oBACrC,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,YAAY,CAChD,kBAAkB,CACnB,CAAC;oBACF,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;oBAC9C,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;oBAChC,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,2BAA2B,CAC3D,kBAAkB,EAClB,OAAO,CACR,CAAC;oBACF,WAAW,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;gBACtC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperlane-xyz/sdk",
|
|
3
3
|
"description": "The official SDK for the Hyperlane Network",
|
|
4
|
-
"version": "12.0.0",
|
|
4
|
+
"version": "12.1.0-cli-bundle.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@arbitrum/sdk": "^4.0.0",
|
|
7
7
|
"@aws-sdk/client-s3": "^3.577.0",
|
|
8
8
|
"@chain-registry/types": "^0.50.14",
|
|
9
9
|
"@cosmjs/cosmwasm-stargate": "^0.32.4",
|
|
10
10
|
"@cosmjs/stargate": "^0.32.4",
|
|
11
|
-
"@hyperlane-xyz/core": "7.0.0",
|
|
12
|
-
"@hyperlane-xyz/utils": "12.0.0",
|
|
11
|
+
"@hyperlane-xyz/core": "7.1.0-cli-bundle.0",
|
|
12
|
+
"@hyperlane-xyz/utils": "12.1.0-cli-bundle.0",
|
|
13
13
|
"@safe-global/api-kit": "1.3.0",
|
|
14
14
|
"@safe-global/protocol-kit": "1.3.0",
|
|
15
15
|
"@safe-global/safe-deployments": "1.37.23",
|