@offckb/cli 0.2.3 → 0.2.5
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/cmd/deploy.js +1 -1
- package/package.json +2 -2
- package/templates/offckb.config.ts +41 -14
package/dist/cmd/deploy.js
CHANGED
|
@@ -113,7 +113,7 @@ function deployBinary(binPath, from, ckb) {
|
|
|
113
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
114
|
const bin = yield (0, fs_2.readFileToUint8Array)(binPath);
|
|
115
115
|
const contractName = (0, fs_2.convertFilenameToUppercase)(binPath);
|
|
116
|
-
const result = yield lumos_1.commons.deploy.
|
|
116
|
+
const result = yield lumos_1.commons.deploy.generateDeployWithTypeIdTx({
|
|
117
117
|
cellProvider: ckb.indexer,
|
|
118
118
|
fromInfo: from.address,
|
|
119
119
|
scriptBinary: bin,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@offckb/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "ckb development network for your first try",
|
|
5
5
|
"author": "Retric Su <retric@cryptape.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"typescript": "^5.3.3"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@ckb-lumos/lumos": "0.
|
|
63
|
+
"@ckb-lumos/lumos": "0.22.2",
|
|
64
64
|
"@inquirer/prompts": "^4.1.0",
|
|
65
65
|
"adm-zip": "^0.5.10",
|
|
66
66
|
"axios": "^1.6.7",
|
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
import { Indexer, RPC, config } from '@ckb-lumos/lumos';
|
|
2
2
|
|
|
3
|
+
export type Network = 'devnet' | 'testnet' | 'mainnet';
|
|
4
|
+
export type AddressPrefix = 'ckb' | 'ckt';
|
|
5
|
+
|
|
3
6
|
export interface NetworkConfig {
|
|
4
7
|
lumosConfig: config.Config;
|
|
5
8
|
rpc_url: string;
|
|
6
9
|
rpc: RPC;
|
|
7
10
|
indexer: Indexer;
|
|
11
|
+
addressPrefix: AddressPrefix;
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
export interface OffCKBConfig {
|
|
11
|
-
version: string;
|
|
12
|
-
lumosVersion: string;
|
|
13
|
-
contractBinFolder: string;
|
|
14
|
-
|
|
15
|
+
readonly version: string;
|
|
16
|
+
readonly lumosVersion: string;
|
|
17
|
+
readonly contractBinFolder: string;
|
|
18
|
+
readonly networks: {
|
|
15
19
|
devnet: NetworkConfig;
|
|
16
20
|
testnet: NetworkConfig;
|
|
17
21
|
mainnet: NetworkConfig;
|
|
18
22
|
};
|
|
19
23
|
initializeLumosConfig: () => void;
|
|
24
|
+
readonly currentNetwork: Network;
|
|
20
25
|
readonly rpc: RPC;
|
|
26
|
+
readonly rpcUrl: string;
|
|
21
27
|
readonly indexer: Indexer;
|
|
22
28
|
readonly lumosConfig: config.Config;
|
|
29
|
+
readonly addressPrefix: AddressPrefix;
|
|
23
30
|
}
|
|
24
31
|
|
|
25
|
-
function readEnvNetwork():
|
|
32
|
+
export function readEnvNetwork(): Network {
|
|
26
33
|
// you may need to update the env method
|
|
27
34
|
// according to your frontend framework
|
|
28
35
|
const network = process.env.NETWORK;
|
|
@@ -33,7 +40,7 @@ function readEnvNetwork(): 'devnet' | 'testnet' | 'mainnet' {
|
|
|
33
40
|
return defaultNetwork;
|
|
34
41
|
}
|
|
35
42
|
|
|
36
|
-
return network as
|
|
43
|
+
return network as Network;
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
// please do not alter the following structure
|
|
@@ -147,46 +154,66 @@ const mainnetLumosConfig: config.Config = { ...config.predefined.LINA, ...{} } a
|
|
|
147
154
|
|
|
148
155
|
const offCKBConfig: OffCKBConfig = {
|
|
149
156
|
version: 'update-me-offckb-config-version',
|
|
150
|
-
lumosVersion: '0.
|
|
151
|
-
contractBinFolder: '
|
|
152
|
-
|
|
157
|
+
lumosVersion: '0.22.2',
|
|
158
|
+
contractBinFolder: '../build/release',
|
|
159
|
+
networks: {
|
|
153
160
|
devnet: {
|
|
154
161
|
lumosConfig,
|
|
155
162
|
rpc_url: 'http://127.0.0.1:8114',
|
|
156
163
|
rpc: new RPC('http://127.0.0.1:8114'),
|
|
157
164
|
indexer: new Indexer('http://127.0.0.1:8114'),
|
|
165
|
+
addressPrefix: 'ckt',
|
|
158
166
|
},
|
|
159
167
|
testnet: {
|
|
160
168
|
lumosConfig: testnetLumosConfig,
|
|
161
169
|
rpc_url: 'https://testnet.ckb.dev/rpc',
|
|
162
170
|
rpc: new RPC('https://testnet.ckb.dev/rpc'),
|
|
163
171
|
indexer: new Indexer('https://testnet.ckb.dev/rpc'),
|
|
172
|
+
addressPrefix: 'ckt',
|
|
164
173
|
},
|
|
165
174
|
mainnet: {
|
|
166
175
|
lumosConfig: mainnetLumosConfig,
|
|
167
176
|
rpc_url: 'https://mainnet.ckb.dev/rpc',
|
|
168
177
|
rpc: new RPC('https://mainnet.ckb.dev/rpc'),
|
|
169
178
|
indexer: new Indexer('https://mainnet.ckb.dev/rpc'),
|
|
179
|
+
addressPrefix: 'ckb',
|
|
170
180
|
},
|
|
171
181
|
},
|
|
172
|
-
|
|
182
|
+
|
|
183
|
+
initializeLumosConfig() {
|
|
173
184
|
const network = readEnvNetwork();
|
|
174
|
-
const lumosConfig =
|
|
185
|
+
const lumosConfig = this.networks[network].lumosConfig;
|
|
175
186
|
return config.initializeConfig(lumosConfig);
|
|
176
187
|
},
|
|
188
|
+
|
|
189
|
+
get currentNetwork() {
|
|
190
|
+
const network = readEnvNetwork();
|
|
191
|
+
return network;
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
get addressPrefix() {
|
|
195
|
+
const network = readEnvNetwork();
|
|
196
|
+
return this.networks[network].addressPrefix;
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
get rpcUrl() {
|
|
200
|
+
const network = readEnvNetwork();
|
|
201
|
+
return this.networks[network].rpc_url;
|
|
202
|
+
},
|
|
203
|
+
|
|
177
204
|
get rpc() {
|
|
178
205
|
const network = readEnvNetwork();
|
|
179
|
-
return
|
|
206
|
+
return this.networks[network].rpc;
|
|
180
207
|
},
|
|
181
208
|
|
|
182
209
|
get indexer() {
|
|
183
210
|
const network = readEnvNetwork();
|
|
184
|
-
return
|
|
211
|
+
return this.networks[network].indexer;
|
|
185
212
|
},
|
|
186
213
|
|
|
187
214
|
get lumosConfig() {
|
|
188
215
|
const network = readEnvNetwork();
|
|
189
|
-
return
|
|
216
|
+
return this.networks[network].lumosConfig;
|
|
190
217
|
},
|
|
191
218
|
};
|
|
192
219
|
|