@agoric/orchestration 0.1.1-dev-e26d66b.0 → 0.1.1-dev-9b9282d.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/package.json +7 -4
- package/src/axelar-types.d.ts +50 -0
- package/src/axelar-types.d.ts.map +1 -0
- package/src/axelar-types.js +75 -0
- package/src/chain-info.d.ts +1000 -83
- package/src/chain-info.d.ts.map +1 -1
- package/src/examples/axelar-gmp-account-kit.d.ts +67 -0
- package/src/examples/axelar-gmp-account-kit.d.ts.map +1 -0
- package/src/examples/axelar-gmp-account-kit.js +361 -0
- package/src/examples/axelar-gmp.contract.d.ts +52 -0
- package/src/examples/axelar-gmp.contract.d.ts.map +1 -0
- package/src/examples/axelar-gmp.contract.js +93 -0
- package/src/examples/axelar-gmp.flows.d.ts +21 -0
- package/src/examples/axelar-gmp.flows.d.ts.map +1 -0
- package/src/examples/axelar-gmp.flows.js +156 -0
- package/src/exos/orchestrator.d.ts +2 -2
- package/src/fetched-chain-info.d.ts +1497 -578
- package/src/fetched-chain-info.js +996 -82
- package/src/proposals/start-axelar-gmp.js +153 -0
- package/src/utils/agd-lib.d.ts +109 -0
- package/src/utils/agd-lib.d.ts.map +1 -0
- package/src/utils/agd-lib.js +167 -0
- package/src/utils/axelar-static-config.d.ts +34 -0
- package/src/utils/axelar-static-config.d.ts.map +1 -0
- package/src/utils/axelar-static-config.js +41 -0
- package/src/utils/gmp.d.ts +61 -0
- package/src/utils/gmp.d.ts.map +1 -0
- package/src/utils/gmp.js +113 -0
- package/tools/contract-tests.d.ts +36 -0
- package/tools/contract-tests.d.ts.map +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/// <reference types="@agoric/vats/src/core/types-ambient"/>
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
deeplyFulfilledObject,
|
|
5
|
+
makeTracer,
|
|
6
|
+
NonNullish,
|
|
7
|
+
} from '@agoric/internal';
|
|
8
|
+
import { E } from '@endo/far';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @import {Issuer} from '@agoric/ertp';
|
|
12
|
+
* @import {Installation, Instance} from '@agoric/zoe/src/zoeService/utils.js';
|
|
13
|
+
* @import {CosmosChainInfo, Denom, DenomDetail} from '@agoric/orchestration';
|
|
14
|
+
* @import {start as StartFn} from '@agoric/orchestration/src/examples/axelar-gmp.contract.js';
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const trace = makeTracer('start axelarGmp', true);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {BootstrapPowers & {
|
|
21
|
+
* installation: {
|
|
22
|
+
* consume: {
|
|
23
|
+
* axelarGmp: Installation<StartFn>;
|
|
24
|
+
* };
|
|
25
|
+
* };
|
|
26
|
+
* instance: {
|
|
27
|
+
* produce: {
|
|
28
|
+
* axelarGmp: Producer<Instance<StartFn>>;
|
|
29
|
+
* };
|
|
30
|
+
* };
|
|
31
|
+
* issuer: {
|
|
32
|
+
* consume: {
|
|
33
|
+
* BLD: Issuer<'nat'>;
|
|
34
|
+
* IST: Issuer<'nat'>;
|
|
35
|
+
* };
|
|
36
|
+
* };
|
|
37
|
+
* }} powers
|
|
38
|
+
* @param {{
|
|
39
|
+
* options: {
|
|
40
|
+
* chainInfo: Record<string, CosmosChainInfo>;
|
|
41
|
+
* assetInfo: [Denom, DenomDetail & { brandKey?: string }][];
|
|
42
|
+
* };
|
|
43
|
+
* }} config
|
|
44
|
+
*/
|
|
45
|
+
export const startAxelarGmp = async (
|
|
46
|
+
{
|
|
47
|
+
consume: {
|
|
48
|
+
agoricNames,
|
|
49
|
+
board,
|
|
50
|
+
chainStorage,
|
|
51
|
+
chainTimerService,
|
|
52
|
+
cosmosInterchainService,
|
|
53
|
+
localchain,
|
|
54
|
+
startUpgradable,
|
|
55
|
+
},
|
|
56
|
+
installation: {
|
|
57
|
+
consume: { axelarGmp },
|
|
58
|
+
},
|
|
59
|
+
instance: {
|
|
60
|
+
produce: { axelarGmp: produceInstance },
|
|
61
|
+
},
|
|
62
|
+
issuer: {
|
|
63
|
+
consume: { BLD, IST },
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{ options: { chainInfo, assetInfo } },
|
|
67
|
+
) => {
|
|
68
|
+
trace(startAxelarGmp.name);
|
|
69
|
+
|
|
70
|
+
const marshaller = await E(board).getReadonlyMarshaller();
|
|
71
|
+
|
|
72
|
+
trace('Setting privateArgs');
|
|
73
|
+
|
|
74
|
+
const privateArgs = await deeplyFulfilledObject(
|
|
75
|
+
harden({
|
|
76
|
+
agoricNames,
|
|
77
|
+
localchain,
|
|
78
|
+
marshaller,
|
|
79
|
+
orchestrationService: cosmosInterchainService,
|
|
80
|
+
storageNode: E(NonNullish(await chainStorage)).makeChildNode('axelarGmp'),
|
|
81
|
+
timerService: chainTimerService,
|
|
82
|
+
chainInfo,
|
|
83
|
+
assetInfo,
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
/** @param {() => Promise<Issuer>} p */
|
|
88
|
+
const safeFulfill = async p =>
|
|
89
|
+
E.when(
|
|
90
|
+
p(),
|
|
91
|
+
i => i,
|
|
92
|
+
() => undefined,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const axlIssuer = await safeFulfill(() =>
|
|
96
|
+
E(agoricNames).lookup('issuer', 'AXL'),
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// const wavaxIssuer = await safeFulfill(() =>
|
|
100
|
+
// E(agoricNames).lookup('issuer', 'WAVAX'),
|
|
101
|
+
// );
|
|
102
|
+
|
|
103
|
+
const issuerKeywordRecord = harden({
|
|
104
|
+
BLD: await BLD,
|
|
105
|
+
IST: await IST,
|
|
106
|
+
...(axlIssuer && { AXL: axlIssuer }),
|
|
107
|
+
// ...(wavaxIssuer && { WAVAX: wavaxIssuer }),
|
|
108
|
+
});
|
|
109
|
+
trace('issuerKeywordRecord', issuerKeywordRecord);
|
|
110
|
+
|
|
111
|
+
trace('Starting contract instance');
|
|
112
|
+
const { instance } = await E(startUpgradable)({
|
|
113
|
+
label: 'axelarGmp',
|
|
114
|
+
installation: axelarGmp,
|
|
115
|
+
issuerKeywordRecord,
|
|
116
|
+
privateArgs,
|
|
117
|
+
});
|
|
118
|
+
produceInstance.resolve(instance);
|
|
119
|
+
trace('done');
|
|
120
|
+
};
|
|
121
|
+
harden(startAxelarGmp);
|
|
122
|
+
|
|
123
|
+
export const getManifest = ({ restoreRef }, { installationRef, options }) => {
|
|
124
|
+
return {
|
|
125
|
+
manifest: {
|
|
126
|
+
[startAxelarGmp.name]: {
|
|
127
|
+
consume: {
|
|
128
|
+
agoricNames: true,
|
|
129
|
+
board: true,
|
|
130
|
+
chainTimerService: true,
|
|
131
|
+
chainStorage: true,
|
|
132
|
+
cosmosInterchainService: true,
|
|
133
|
+
localchain: true,
|
|
134
|
+
|
|
135
|
+
startUpgradable: true,
|
|
136
|
+
},
|
|
137
|
+
installation: {
|
|
138
|
+
consume: { axelarGmp: true },
|
|
139
|
+
},
|
|
140
|
+
instance: {
|
|
141
|
+
produce: { axelarGmp: true },
|
|
142
|
+
},
|
|
143
|
+
issuer: {
|
|
144
|
+
consume: { BLD: true, IST: true },
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
installations: {
|
|
149
|
+
axelarGmp: restoreRef(installationRef),
|
|
150
|
+
},
|
|
151
|
+
options,
|
|
152
|
+
};
|
|
153
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export function flags(record: Record<string, unknown>): string[];
|
|
2
|
+
export function makeAgd({ execFileSync, log }: {
|
|
3
|
+
execFileSync: ExecSync;
|
|
4
|
+
log?: typeof console.log;
|
|
5
|
+
}): Readonly<{
|
|
6
|
+
readOnly: () => Readonly<{
|
|
7
|
+
status: () => Promise<any>;
|
|
8
|
+
/**
|
|
9
|
+
* @param {[kind: 'gov', domain: string, ...rest: any]
|
|
10
|
+
* | [kind: 'tx', txhash: string]
|
|
11
|
+
* | [mod: 'vstorage', kind: 'data' | 'children', path: string]
|
|
12
|
+
* | [mod: 'ibc', ...rest: string[]]} qArgs
|
|
13
|
+
*/
|
|
14
|
+
query: (qArgs: [kind: "gov", domain: string, ...rest: any] | [kind: "tx", txhash: string] | [mod: "vstorage", kind: "data" | "children", path: string] | [mod: "ibc", ...rest: string[]]) => Promise<any>;
|
|
15
|
+
}>;
|
|
16
|
+
nameHub: () => Readonly<{
|
|
17
|
+
/**
|
|
18
|
+
* NOTE: synchronous I/O
|
|
19
|
+
*
|
|
20
|
+
* @param {string[]} path
|
|
21
|
+
*/
|
|
22
|
+
lookup: (...path: string[]) => string;
|
|
23
|
+
}>;
|
|
24
|
+
keys: {
|
|
25
|
+
/**
|
|
26
|
+
* @param {string} name
|
|
27
|
+
* @param {string} mnemonic
|
|
28
|
+
*/
|
|
29
|
+
add: (name: string, mnemonic: string) => string;
|
|
30
|
+
showAddress: (...path: string[]) => string;
|
|
31
|
+
/** @param {string} name */
|
|
32
|
+
delete: (name: string) => string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* @param {Record<string, unknown>} opts
|
|
36
|
+
*/
|
|
37
|
+
withOpts: (opts: Record<string, unknown>) => Readonly</*elided*/ any>;
|
|
38
|
+
lookup: (...path: string[]) => string;
|
|
39
|
+
status: () => Promise<any>;
|
|
40
|
+
query: (qArgs: [kind: "gov", domain: string, ...rest: any] | [kind: "tx", txhash: string] | [mod: "vstorage", kind: "data" | "children", path: string] | [mod: "ibc", ...rest: string[]]) => Promise<any>;
|
|
41
|
+
/**
|
|
42
|
+
* TODO: gas
|
|
43
|
+
*
|
|
44
|
+
* @param {string[]} txArgs
|
|
45
|
+
* @param {{ chainId: string; from: string; yes?: boolean }} opts
|
|
46
|
+
*/
|
|
47
|
+
tx: (txArgs: string[], { chainId, from, yes }: {
|
|
48
|
+
chainId: string;
|
|
49
|
+
from: string;
|
|
50
|
+
yes?: boolean;
|
|
51
|
+
}) => Promise<any>;
|
|
52
|
+
}>;
|
|
53
|
+
export type ExecSync = (file: string, args: string[], opts: {
|
|
54
|
+
encoding: "utf-8";
|
|
55
|
+
} & {
|
|
56
|
+
[k: string]: unknown;
|
|
57
|
+
}) => string;
|
|
58
|
+
export type Agd = ReturnType<({ execFileSync, log }: {
|
|
59
|
+
execFileSync: ExecSync;
|
|
60
|
+
log?: typeof console.log;
|
|
61
|
+
}) => Readonly<{
|
|
62
|
+
readOnly: () => Readonly<{
|
|
63
|
+
status: () => Promise<any>;
|
|
64
|
+
/**
|
|
65
|
+
* @param {[kind: 'gov', domain: string, ...rest: any]
|
|
66
|
+
* | [kind: 'tx', txhash: string]
|
|
67
|
+
* | [mod: 'vstorage', kind: 'data' | 'children', path: string]
|
|
68
|
+
* | [mod: 'ibc', ...rest: string[]]} qArgs
|
|
69
|
+
*/
|
|
70
|
+
query: (qArgs: [kind: "gov", domain: string, ...rest: any] | [kind: "tx", txhash: string] | [mod: "vstorage", kind: "data" | "children", path: string] | [mod: "ibc", ...rest: string[]]) => Promise<any>;
|
|
71
|
+
}>;
|
|
72
|
+
nameHub: () => Readonly<{
|
|
73
|
+
/**
|
|
74
|
+
* NOTE: synchronous I/O
|
|
75
|
+
*
|
|
76
|
+
* @param {string[]} path
|
|
77
|
+
*/
|
|
78
|
+
lookup: (...path: string[]) => string;
|
|
79
|
+
}>;
|
|
80
|
+
keys: {
|
|
81
|
+
/**
|
|
82
|
+
* @param {string} name
|
|
83
|
+
* @param {string} mnemonic
|
|
84
|
+
*/
|
|
85
|
+
add: (name: string, mnemonic: string) => string;
|
|
86
|
+
showAddress: (...path: string[]) => string;
|
|
87
|
+
/** @param {string} name */
|
|
88
|
+
delete: (name: string) => string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* @param {Record<string, unknown>} opts
|
|
92
|
+
*/
|
|
93
|
+
withOpts: (opts: Record<string, unknown>) => Readonly</*elided*/ any>;
|
|
94
|
+
lookup: (...path: string[]) => string;
|
|
95
|
+
status: () => Promise<any>;
|
|
96
|
+
query: (qArgs: [kind: "gov", domain: string, ...rest: any] | [kind: "tx", txhash: string] | [mod: "vstorage", kind: "data" | "children", path: string] | [mod: "ibc", ...rest: string[]]) => Promise<any>;
|
|
97
|
+
/**
|
|
98
|
+
* TODO: gas
|
|
99
|
+
*
|
|
100
|
+
* @param {string[]} txArgs
|
|
101
|
+
* @param {{ chainId: string; from: string; yes?: boolean }} opts
|
|
102
|
+
*/
|
|
103
|
+
tx: (txArgs: string[], { chainId, from, yes }: {
|
|
104
|
+
chainId: string;
|
|
105
|
+
from: string;
|
|
106
|
+
yes?: boolean;
|
|
107
|
+
}) => Promise<any>;
|
|
108
|
+
}>>;
|
|
109
|
+
//# sourceMappingURL=agd-lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agd-lib.d.ts","sourceRoot":"","sources":["agd-lib.js"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
|
|
3
|
+
const { freeze } = Object;
|
|
4
|
+
|
|
5
|
+
const agdBinary = 'agd';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {Record<string, unknown>} record - e.g. { color: 'blue' }
|
|
9
|
+
* @returns {string[]} - e.g. ['--color', 'blue']
|
|
10
|
+
*/
|
|
11
|
+
export const flags = record => {
|
|
12
|
+
// TODO? support --yes with boolean?
|
|
13
|
+
|
|
14
|
+
/** @type {[string, string][]} */
|
|
15
|
+
// @ts-expect-error undefined is filtered out
|
|
16
|
+
const skipUndef = Object.entries(record).filter(([_k, v]) => v !== undefined);
|
|
17
|
+
return skipUndef.map(([k, v]) => [`--${k}`, v]).flat();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @callback ExecSync
|
|
22
|
+
* @param {string} file
|
|
23
|
+
* @param {string[]} args
|
|
24
|
+
* @param {{ encoding: 'utf-8' } & { [k: string]: unknown }} opts
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {{ execFileSync: ExecSync; log?: typeof console.log }} io
|
|
30
|
+
*/
|
|
31
|
+
export const makeAgd = ({ execFileSync, log = console.log }) => {
|
|
32
|
+
/**
|
|
33
|
+
* @param {{
|
|
34
|
+
* home?: string;
|
|
35
|
+
* keyringBackend?: string;
|
|
36
|
+
* rpcAddrs?: string[];
|
|
37
|
+
* }} opts
|
|
38
|
+
*/
|
|
39
|
+
const make = ({ home, keyringBackend, rpcAddrs } = {}) => {
|
|
40
|
+
const keyringArgs = flags({ home, 'keyring-backend': keyringBackend });
|
|
41
|
+
if (rpcAddrs) {
|
|
42
|
+
assert.equal(
|
|
43
|
+
rpcAddrs.length,
|
|
44
|
+
1,
|
|
45
|
+
'XXX rpcAddrs must contain only one entry',
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
const nodeArgs = flags({ node: rpcAddrs && rpcAddrs[0] });
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {string[]} args
|
|
52
|
+
* @param {any} [opts]
|
|
53
|
+
*/
|
|
54
|
+
const exec = (args, opts = { encoding: 'utf-8' }) =>
|
|
55
|
+
execFileSync(agdBinary, args, opts);
|
|
56
|
+
|
|
57
|
+
const outJson = flags({ output: 'json' });
|
|
58
|
+
|
|
59
|
+
const ro = freeze({
|
|
60
|
+
status: async () => JSON.parse(exec([...nodeArgs, 'status'])),
|
|
61
|
+
/**
|
|
62
|
+
* @param {[kind: 'gov', domain: string, ...rest: any]
|
|
63
|
+
* | [kind: 'tx', txhash: string]
|
|
64
|
+
* | [mod: 'vstorage', kind: 'data' | 'children', path: string]
|
|
65
|
+
* | [mod: 'ibc', ...rest: string[]]} qArgs
|
|
66
|
+
*/
|
|
67
|
+
query: async qArgs => {
|
|
68
|
+
const out = exec(['query', ...qArgs, ...nodeArgs, ...outJson], {
|
|
69
|
+
encoding: 'utf-8',
|
|
70
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
return JSON.parse(out);
|
|
75
|
+
} catch (e) {
|
|
76
|
+
console.error(e);
|
|
77
|
+
console.info('output:', out);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
const nameHub = freeze({
|
|
82
|
+
/**
|
|
83
|
+
* NOTE: synchronous I/O
|
|
84
|
+
*
|
|
85
|
+
* @param {string[]} path
|
|
86
|
+
*/
|
|
87
|
+
lookup: (...path) => {
|
|
88
|
+
if (!Array.isArray(path)) {
|
|
89
|
+
// TODO: use COND || Fail``
|
|
90
|
+
throw TypeError();
|
|
91
|
+
}
|
|
92
|
+
if (path.length !== 1) {
|
|
93
|
+
throw Error(`path length limited to 1: ${path.length}`);
|
|
94
|
+
}
|
|
95
|
+
const [name] = path;
|
|
96
|
+
const txt = exec(['keys', 'show', `--address`, name, ...keyringArgs]);
|
|
97
|
+
return txt.trim();
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
const rw = freeze({
|
|
101
|
+
/**
|
|
102
|
+
* TODO: gas
|
|
103
|
+
*
|
|
104
|
+
* @param {string[]} txArgs
|
|
105
|
+
* @param {{ chainId: string; from: string; yes?: boolean }} opts
|
|
106
|
+
*/
|
|
107
|
+
tx: async (txArgs, { chainId, from, yes }) => {
|
|
108
|
+
const args = [
|
|
109
|
+
'tx',
|
|
110
|
+
...txArgs,
|
|
111
|
+
...nodeArgs,
|
|
112
|
+
...keyringArgs,
|
|
113
|
+
...flags({ 'chain-id': chainId, from }),
|
|
114
|
+
...flags({
|
|
115
|
+
'broadcast-mode': 'block',
|
|
116
|
+
gas: 'auto',
|
|
117
|
+
'gas-adjustment': '1.4',
|
|
118
|
+
}),
|
|
119
|
+
...(yes ? ['--yes'] : []),
|
|
120
|
+
...outJson,
|
|
121
|
+
];
|
|
122
|
+
log('$$$', agdBinary, ...args);
|
|
123
|
+
const out = exec(args);
|
|
124
|
+
try {
|
|
125
|
+
const detail = JSON.parse(out);
|
|
126
|
+
if (detail.code !== 0) {
|
|
127
|
+
throw Error(detail.raw_log);
|
|
128
|
+
}
|
|
129
|
+
return detail;
|
|
130
|
+
} catch (e) {
|
|
131
|
+
console.error(e);
|
|
132
|
+
console.info('output:', out);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
...ro,
|
|
136
|
+
...nameHub,
|
|
137
|
+
readOnly: () => ro,
|
|
138
|
+
nameHub: () => nameHub,
|
|
139
|
+
keys: {
|
|
140
|
+
/**
|
|
141
|
+
* @param {string} name
|
|
142
|
+
* @param {string} mnemonic
|
|
143
|
+
*/
|
|
144
|
+
add: (name, mnemonic) => {
|
|
145
|
+
return execFileSync(
|
|
146
|
+
agdBinary,
|
|
147
|
+
[...keyringArgs, 'keys', 'add', name, '--recover'],
|
|
148
|
+
{ encoding: 'utf-8', input: mnemonic },
|
|
149
|
+
).toString();
|
|
150
|
+
},
|
|
151
|
+
showAddress: nameHub.lookup,
|
|
152
|
+
/** @param {string} name */
|
|
153
|
+
delete: name => {
|
|
154
|
+
return exec([...keyringArgs, 'keys', 'delete', name, '-y']);
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
/**
|
|
158
|
+
* @param {Record<string, unknown>} opts
|
|
159
|
+
*/
|
|
160
|
+
withOpts: opts => make({ home, keyringBackend, rpcAddrs, ...opts }),
|
|
161
|
+
});
|
|
162
|
+
return rw;
|
|
163
|
+
};
|
|
164
|
+
return make();
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/** @typedef {ReturnType<makeAgd>} Agd */
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Brand} from '@agoric/ertp';
|
|
3
|
+
* @import {Denom} from '@agoric/orchestration';
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {object} DenomDetail
|
|
7
|
+
* @property {string} baseName - name of issuing chain; e.g. cosmoshub
|
|
8
|
+
* @property {Denom} baseDenom - e.g. uatom
|
|
9
|
+
* @property {string} chainName - name of holding chain; e.g. agoric
|
|
10
|
+
* @property {Brand<'nat'>} [brand] - vbank brand, if registered
|
|
11
|
+
* @see {ChainHub} `registerAsset` method
|
|
12
|
+
*/
|
|
13
|
+
export const assetInfo: string;
|
|
14
|
+
export type DenomDetail = {
|
|
15
|
+
/**
|
|
16
|
+
* - name of issuing chain; e.g. cosmoshub
|
|
17
|
+
*/
|
|
18
|
+
baseName: string;
|
|
19
|
+
/**
|
|
20
|
+
* - e.g. uatom
|
|
21
|
+
*/
|
|
22
|
+
baseDenom: Denom;
|
|
23
|
+
/**
|
|
24
|
+
* - name of holding chain; e.g. agoric
|
|
25
|
+
*/
|
|
26
|
+
chainName: string;
|
|
27
|
+
/**
|
|
28
|
+
* - vbank brand, if registered
|
|
29
|
+
*/
|
|
30
|
+
brand?: Brand<"nat"> | undefined;
|
|
31
|
+
};
|
|
32
|
+
import type { Denom } from '@agoric/orchestration';
|
|
33
|
+
import type { Brand } from '@agoric/ertp';
|
|
34
|
+
//# sourceMappingURL=axelar-static-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axelar-static-config.d.ts","sourceRoot":"","sources":["axelar-static-config.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,+BA0BG;;;;;cAjCW,MAAM;;;;eACN,KAAK;;;;eACL,MAAM;;;;;;2BAPI,uBAAuB;2BADvB,cAAc"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Brand} from '@agoric/ertp';
|
|
3
|
+
* @import {Denom} from '@agoric/orchestration';
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {object} DenomDetail
|
|
8
|
+
* @property {string} baseName - name of issuing chain; e.g. cosmoshub
|
|
9
|
+
* @property {Denom} baseDenom - e.g. uatom
|
|
10
|
+
* @property {string} chainName - name of holding chain; e.g. agoric
|
|
11
|
+
* @property {Brand<'nat'>} [brand] - vbank brand, if registered
|
|
12
|
+
* @see {ChainHub} `registerAsset` method
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const assetInfo = JSON.stringify([
|
|
16
|
+
[
|
|
17
|
+
'uist',
|
|
18
|
+
{
|
|
19
|
+
baseDenom: 'uist',
|
|
20
|
+
baseName: 'agoric',
|
|
21
|
+
chainName: 'agoric',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
'ubld',
|
|
26
|
+
{
|
|
27
|
+
baseDenom: 'ubld',
|
|
28
|
+
baseName: 'agoric',
|
|
29
|
+
chainName: 'agoric',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
[
|
|
33
|
+
'ibc/2CC0B1B7A981ACC74854717F221008484603BB8360E81B262411B0D830EDE9B0',
|
|
34
|
+
{
|
|
35
|
+
baseDenom: 'uaxl',
|
|
36
|
+
baseName: 'axelar',
|
|
37
|
+
chainName: 'agoric',
|
|
38
|
+
brandKey: 'AXL',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
]);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export namespace GMPMessageType {
|
|
2
|
+
let MESSAGE_ONLY: number;
|
|
3
|
+
let MESSAGE_WITH_TOKEN: number;
|
|
4
|
+
let TOKEN_ONLY: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @type {{
|
|
8
|
+
* AXELAR_GMP: Bech32Address;
|
|
9
|
+
* AXELAR_GAS: Bech32Address;
|
|
10
|
+
* OSMOSIS_RECEIVER: Bech32Address;
|
|
11
|
+
* }}
|
|
12
|
+
*/
|
|
13
|
+
export const gmpAddresses: {
|
|
14
|
+
AXELAR_GMP: Bech32Address;
|
|
15
|
+
AXELAR_GAS: Bech32Address;
|
|
16
|
+
OSMOSIS_RECEIVER: Bech32Address;
|
|
17
|
+
};
|
|
18
|
+
export function constructContractCall({ target, functionSignature, args }: ContractCall): AbiEncodedContractCall;
|
|
19
|
+
export function buildGMPPayload(contractCalls: ContractCall[]): number[];
|
|
20
|
+
export namespace networkConfigs {
|
|
21
|
+
namespace devnet {
|
|
22
|
+
let label: string;
|
|
23
|
+
let url: string;
|
|
24
|
+
let rpc: string;
|
|
25
|
+
let api: string;
|
|
26
|
+
let chainId: string;
|
|
27
|
+
}
|
|
28
|
+
namespace emerynet {
|
|
29
|
+
let label_1: string;
|
|
30
|
+
export { label_1 as label };
|
|
31
|
+
let url_1: string;
|
|
32
|
+
export { url_1 as url };
|
|
33
|
+
let rpc_1: string;
|
|
34
|
+
export { rpc_1 as rpc };
|
|
35
|
+
let api_1: string;
|
|
36
|
+
export { api_1 as api };
|
|
37
|
+
let chainId_1: string;
|
|
38
|
+
export { chainId_1 as chainId };
|
|
39
|
+
}
|
|
40
|
+
namespace localhost {
|
|
41
|
+
let label_2: string;
|
|
42
|
+
export { label_2 as label };
|
|
43
|
+
let url_2: string;
|
|
44
|
+
export { url_2 as url };
|
|
45
|
+
let rpc_2: string;
|
|
46
|
+
export { rpc_2 as rpc };
|
|
47
|
+
let api_2: string;
|
|
48
|
+
export { api_2 as api };
|
|
49
|
+
let chainId_2: string;
|
|
50
|
+
export { chainId_2 as chainId };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export namespace EVM_CHAINS {
|
|
54
|
+
let Avalanche: string;
|
|
55
|
+
let Base: string;
|
|
56
|
+
let Ethereum: string;
|
|
57
|
+
}
|
|
58
|
+
import type { Bech32Address } from '@agoric/orchestration';
|
|
59
|
+
import type { ContractCall } from '../axelar-types.js';
|
|
60
|
+
import type { AbiEncodedContractCall } from '../axelar-types.js';
|
|
61
|
+
//# sourceMappingURL=gmp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gmp.d.ts","sourceRoot":"","sources":["gmp.js"],"names":[],"mappings":";;;;;AAaA;;;;;;GAMG;AACH,2BANU;IACL,UAAU,EAAE,aAAa,CAAC;IAC1B,UAAU,EAAE,aAAa,CAAC;IAC1B,gBAAgB,EAAE,aAAa,CAAC;CACjC,CAOF;AAQK,2EAHI,YAAY,GACV,sBAAsB,CAoBlC;AAQM,+CAHI,YAAY,EAAE,GACZ,MAAM,EAAE,CAyBpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCA9E+B,uBAAuB;kCADA,oBAAoB;4CAApB,oBAAoB"}
|
package/src/utils/gmp.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { encodeFunctionData, encodeAbiParameters, hexToBytes } from 'viem';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @import {ContractCall, AbiEncodedContractCall} from '../axelar-types.js';
|
|
5
|
+
* @import {Bech32Address} from '@agoric/orchestration';
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const GMPMessageType = {
|
|
9
|
+
MESSAGE_ONLY: 1,
|
|
10
|
+
MESSAGE_WITH_TOKEN: 2,
|
|
11
|
+
TOKEN_ONLY: 3,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @type {{
|
|
16
|
+
* AXELAR_GMP: Bech32Address;
|
|
17
|
+
* AXELAR_GAS: Bech32Address;
|
|
18
|
+
* OSMOSIS_RECEIVER: Bech32Address;
|
|
19
|
+
* }}
|
|
20
|
+
*/
|
|
21
|
+
export const gmpAddresses = {
|
|
22
|
+
AXELAR_GMP:
|
|
23
|
+
'axelar1dv4u5k73pzqrxlzujxg3qp8kvc3pje7jtdvu72npnt5zhq05ejcsn5qme5',
|
|
24
|
+
AXELAR_GAS: 'axelar1zl3rxpp70lmte2xr6c4lgske2fyuj3hupcsvcd',
|
|
25
|
+
OSMOSIS_RECEIVER: 'osmo1yh3ra8eage5xtr9a3m5utg6mx0pmqreytudaqj',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Constructs a contract call object with ABI encoding.
|
|
30
|
+
*
|
|
31
|
+
* @param {ContractCall} data - The data for the contract call.
|
|
32
|
+
* @returns {AbiEncodedContractCall} The encoded contract call object.
|
|
33
|
+
*/
|
|
34
|
+
export const constructContractCall = ({ target, functionSignature, args }) => {
|
|
35
|
+
const [name, paramsRaw] = functionSignature.split('(');
|
|
36
|
+
const params = paramsRaw.replace(')', '').split(',').filter(Boolean);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
target,
|
|
40
|
+
data: encodeFunctionData({
|
|
41
|
+
abi: [
|
|
42
|
+
{
|
|
43
|
+
type: 'function',
|
|
44
|
+
name,
|
|
45
|
+
inputs: params.map((type, i) => ({ type, name: `arg${i}` })),
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
functionName: name,
|
|
49
|
+
args,
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Builds a GMP payload from an array of contract calls.
|
|
56
|
+
*
|
|
57
|
+
* @param {ContractCall[]} contractCalls - Array of contract call objects.
|
|
58
|
+
* @returns {number[]} The GMP payload object.
|
|
59
|
+
*/
|
|
60
|
+
export const buildGMPPayload = contractCalls => {
|
|
61
|
+
const abiEncodedContractCalls = [];
|
|
62
|
+
for (const call of contractCalls) {
|
|
63
|
+
const { target, functionSignature, args } = call;
|
|
64
|
+
abiEncodedContractCalls.push(
|
|
65
|
+
constructContractCall({ target, functionSignature, args }),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const abiEncodedData = encodeAbiParameters(
|
|
70
|
+
[
|
|
71
|
+
{
|
|
72
|
+
type: 'tuple[]',
|
|
73
|
+
components: [
|
|
74
|
+
{ name: 'target', type: 'address' },
|
|
75
|
+
{ name: 'data', type: 'bytes' },
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
[abiEncodedContractCalls],
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return Array.from(hexToBytes(abiEncodedData));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const networkConfigs = {
|
|
86
|
+
devnet: {
|
|
87
|
+
label: 'Agoric Devnet',
|
|
88
|
+
url: 'https://devnet.agoric.net/network-config',
|
|
89
|
+
rpc: 'https://devnet.rpc.agoric.net',
|
|
90
|
+
api: 'https://devnet.api.agoric.net',
|
|
91
|
+
chainId: 'agoricdev-25',
|
|
92
|
+
},
|
|
93
|
+
emerynet: {
|
|
94
|
+
label: 'Agoric Emerynet',
|
|
95
|
+
url: 'https://emerynet.agoric.net/network-config',
|
|
96
|
+
rpc: 'https://emerynet.rpc.agoric.net',
|
|
97
|
+
api: 'https://emerynet.api.agoric.net',
|
|
98
|
+
chainId: 'agoric-emerynet-9',
|
|
99
|
+
},
|
|
100
|
+
localhost: {
|
|
101
|
+
label: 'Local Network',
|
|
102
|
+
url: 'https://local.agoric.net/network-config',
|
|
103
|
+
rpc: 'http://localhost:26657',
|
|
104
|
+
api: 'http://localhost:1317',
|
|
105
|
+
chainId: 'agoriclocal',
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const EVM_CHAINS = {
|
|
110
|
+
Avalanche: 'Avalanche',
|
|
111
|
+
Base: 'base-sepolia',
|
|
112
|
+
Ethereum: 'ethereum-sepolia',
|
|
113
|
+
};
|