@recoillink/tron-sdk 0.0.0-stage → 26.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 +44 -2
- package/dist/clients/protocol.d.ts +27 -0
- package/dist/clients/protocol.d.ts.map +1 -0
- package/dist/clients/protocol.js +53 -0
- package/dist/clients/protocol.js.map +1 -0
- package/dist/clients/provider.d.ts +30 -0
- package/dist/clients/provider.d.ts.map +1 -0
- package/dist/clients/provider.js +268 -0
- package/dist/clients/provider.js.map +1 -0
- package/dist/clients/signer.d.ts +16 -0
- package/dist/clients/signer.d.ts.map +1 -0
- package/dist/clients/signer.js +38 -0
- package/dist/clients/signer.js.map +1 -0
- package/dist/ethers/TronContractFactory.d.ts +32 -0
- package/dist/ethers/TronContractFactory.d.ts.map +1 -0
- package/dist/ethers/TronContractFactory.js +54 -0
- package/dist/ethers/TronContractFactory.js.map +1 -0
- package/dist/ethers/TronJsonRpcProvider.d.ts +74 -0
- package/dist/ethers/TronJsonRpcProvider.d.ts.map +1 -0
- package/dist/ethers/TronJsonRpcProvider.integration.test.d.ts +2 -0
- package/dist/ethers/TronJsonRpcProvider.integration.test.d.ts.map +1 -0
- package/dist/ethers/TronJsonRpcProvider.integration.test.js +46 -0
- package/dist/ethers/TronJsonRpcProvider.integration.test.js.map +1 -0
- package/dist/ethers/TronJsonRpcProvider.js +261 -0
- package/dist/ethers/TronJsonRpcProvider.js.map +1 -0
- package/dist/ethers/TronJsonRpcProvider.test.d.ts +2 -0
- package/dist/ethers/TronJsonRpcProvider.test.d.ts.map +1 -0
- package/dist/ethers/TronJsonRpcProvider.test.js +336 -0
- package/dist/ethers/TronJsonRpcProvider.test.js.map +1 -0
- package/dist/ethers/TronWallet.d.ts +69 -0
- package/dist/ethers/TronWallet.d.ts.map +1 -0
- package/dist/ethers/TronWallet.integration.test.d.ts +2 -0
- package/dist/ethers/TronWallet.integration.test.d.ts.map +1 -0
- package/dist/ethers/TronWallet.integration.test.js +151 -0
- package/dist/ethers/TronWallet.integration.test.js.map +1 -0
- package/dist/ethers/TronWallet.js +295 -0
- package/dist/ethers/TronWallet.js.map +1 -0
- package/dist/ethers/TronWallet.test.d.ts +2 -0
- package/dist/ethers/TronWallet.test.d.ts.map +1 -0
- package/dist/ethers/TronWallet.test.js +216 -0
- package/dist/ethers/TronWallet.test.js.map +1 -0
- package/dist/ethers/index.d.ts +4 -0
- package/dist/ethers/index.d.ts.map +1 -0
- package/dist/ethers/index.js +4 -0
- package/dist/ethers/index.js.map +1 -0
- package/dist/ethers/urlUtils.d.ts +32 -0
- package/dist/ethers/urlUtils.d.ts.map +1 -0
- package/dist/ethers/urlUtils.js +67 -0
- package/dist/ethers/urlUtils.js.map +1 -0
- package/dist/ethers/urlUtils.test.d.ts +2 -0
- package/dist/ethers/urlUtils.test.d.ts.map +1 -0
- package/dist/ethers/urlUtils.test.js +106 -0
- package/dist/ethers/urlUtils.test.js.map +1 -0
- package/dist/factories/index.d.ts +2 -0
- package/dist/factories/index.d.ts.map +1 -0
- package/dist/factories/index.js +8 -0
- package/dist/factories/index.js.map +1 -0
- package/dist/hook/hook-query.d.ts +41 -0
- package/dist/hook/hook-query.d.ts.map +1 -0
- package/dist/hook/hook-query.js +79 -0
- package/dist/hook/hook-query.js.map +1 -0
- package/dist/hook/hook-tx.d.ts +39 -0
- package/dist/hook/hook-tx.d.ts.map +1 -0
- package/dist/hook/hook-tx.js +95 -0
- package/dist/hook/hook-tx.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/ism/ism-query.d.ts +70 -0
- package/dist/ism/ism-query.d.ts.map +1 -0
- package/dist/ism/ism-query.js +137 -0
- package/dist/ism/ism-query.js.map +1 -0
- package/dist/ism/ism-tx.d.ts +67 -0
- package/dist/ism/ism-tx.d.ts.map +1 -0
- package/dist/ism/ism-tx.js +110 -0
- package/dist/ism/ism-tx.js.map +1 -0
- package/dist/runtime.d.ts +8 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +6 -0
- package/dist/runtime.js.map +1 -0
- package/dist/testing/constants.d.ts +7 -0
- package/dist/testing/constants.d.ts.map +1 -0
- package/dist/testing/constants.js +7 -0
- package/dist/testing/constants.js.map +1 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +4 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/node.d.ts +41 -0
- package/dist/testing/node.d.ts.map +1 -0
- package/dist/testing/node.js +119 -0
- package/dist/testing/node.js.map +1 -0
- package/dist/utils/index.d.ts +68 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +141 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.test.d.ts +2 -0
- package/dist/utils/index.test.d.ts.map +1 -0
- package/dist/utils/index.test.js +85 -0
- package/dist/utils/index.test.js.map +1 -0
- package/dist/utils/types.d.ts +94 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +13 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +74 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse custom_rpc_header query params from a URL into a headers object.
|
|
3
|
+
* e.g. "https://api.trongrid.io?custom_rpc_header=TRON-PRO-API-KEY:abc"
|
|
4
|
+
* returns { "TRON-PRO-API-KEY": "abc" }
|
|
5
|
+
*/
|
|
6
|
+
export function parseCustomHeaders(url) {
|
|
7
|
+
const headers = {};
|
|
8
|
+
try {
|
|
9
|
+
const parsed = new URL(url);
|
|
10
|
+
for (const [key, value] of parsed.searchParams) {
|
|
11
|
+
if (key !== 'custom_rpc_header')
|
|
12
|
+
continue;
|
|
13
|
+
const colonIdx = value.indexOf(':');
|
|
14
|
+
if (colonIdx > 0) {
|
|
15
|
+
headers[value.slice(0, colonIdx)] = value.slice(colonIdx + 1);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Not a valid URL, return empty headers
|
|
21
|
+
}
|
|
22
|
+
return headers;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Strip custom_rpc_header query params from a URL and return the clean URL
|
|
26
|
+
* along with the extracted headers.
|
|
27
|
+
*
|
|
28
|
+
* e.g. "https://host/jsonrpc?custom_rpc_header=x-api-key:abc&other=1"
|
|
29
|
+
* returns { url: "https://host/jsonrpc?other=1", headers: { "x-api-key": "abc" } }
|
|
30
|
+
*
|
|
31
|
+
* If no custom_rpc_header params are present, returns the original URL unchanged.
|
|
32
|
+
*/
|
|
33
|
+
export function stripCustomRpcHeaders(url) {
|
|
34
|
+
const headers = parseCustomHeaders(url);
|
|
35
|
+
let parsed;
|
|
36
|
+
try {
|
|
37
|
+
parsed = new URL(url);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return { url, headers };
|
|
41
|
+
}
|
|
42
|
+
if (!parsed.searchParams.has('custom_rpc_header')) {
|
|
43
|
+
return { url, headers };
|
|
44
|
+
}
|
|
45
|
+
parsed.searchParams.delete('custom_rpc_header');
|
|
46
|
+
return { url: parsed.toString(), headers };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Derive the Tron HTTP API base host from an RPC URL.
|
|
50
|
+
*
|
|
51
|
+
* TronWeb needs the base HTTP API host (serving `/wallet/*`), which differs
|
|
52
|
+
* from the ethers JSON-RPC endpoint. This strips any `custom_rpc_header` query
|
|
53
|
+
* params (they are auth headers, not part of the host) and a trailing
|
|
54
|
+
* `/jsonrpc` path segment.
|
|
55
|
+
*
|
|
56
|
+
* e.g. "https://node.example.com/jsonrpc?custom_rpc_header=x-api-key:abc"
|
|
57
|
+
* returns "https://node.example.com/"
|
|
58
|
+
*/
|
|
59
|
+
export function toHttpApiUrl(url) {
|
|
60
|
+
const { url: clean } = stripCustomRpcHeaders(url);
|
|
61
|
+
const parsed = new URL(clean);
|
|
62
|
+
if (parsed.pathname.endsWith('/jsonrpc')) {
|
|
63
|
+
parsed.pathname = parsed.pathname.slice(0, -'/jsonrpc'.length);
|
|
64
|
+
}
|
|
65
|
+
return parsed.toString();
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=urlUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlUtils.js","sourceRoot":"","sources":["../../src/ethers/urlUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YAC/C,IAAI,GAAG,KAAK,mBAAmB;gBAAE,SAAS;YAC1C,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACpC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;gBACjB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,wCAAwC;IAC1C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAI/C,MAAM,OAAO,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,MAAW,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;IAC1B,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAClD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;IAC1B,CAAC;IACD,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAChD,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACzC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlUtils.test.d.ts","sourceRoot":"","sources":["../../src/ethers/urlUtils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { parseCustomHeaders, stripCustomRpcHeaders, toHttpApiUrl, } from './urlUtils.js';
|
|
3
|
+
describe('parseCustomHeaders', () => {
|
|
4
|
+
it('extracts a single custom_rpc_header', () => {
|
|
5
|
+
const url = 'https://api.trongrid.io?custom_rpc_header=TRON-PRO-API-KEY:abc123';
|
|
6
|
+
expect(parseCustomHeaders(url)).to.deep.equal({
|
|
7
|
+
'TRON-PRO-API-KEY': 'abc123',
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
it('extracts multiple custom_rpc_header params', () => {
|
|
11
|
+
const url = 'https://host?custom_rpc_header=x-api-key:key1&custom_rpc_header=Authorization:Bearer%20token';
|
|
12
|
+
expect(parseCustomHeaders(url)).to.deep.equal({
|
|
13
|
+
'x-api-key': 'key1',
|
|
14
|
+
Authorization: 'Bearer token',
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
it('handles header values with colons', () => {
|
|
18
|
+
const url = 'https://host?custom_rpc_header=x-api-key:token:with:colons';
|
|
19
|
+
expect(parseCustomHeaders(url)).to.deep.equal({
|
|
20
|
+
'x-api-key': 'token:with:colons',
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
it('returns empty object for URL without custom_rpc_header', () => {
|
|
24
|
+
const url = 'https://api.trongrid.io/jsonrpc';
|
|
25
|
+
expect(parseCustomHeaders(url)).to.deep.equal({});
|
|
26
|
+
});
|
|
27
|
+
it('returns empty object for invalid URL', () => {
|
|
28
|
+
expect(parseCustomHeaders('not-a-url')).to.deep.equal({});
|
|
29
|
+
});
|
|
30
|
+
it('ignores malformed header values without colon', () => {
|
|
31
|
+
const url = 'https://host?custom_rpc_header=nocolon';
|
|
32
|
+
expect(parseCustomHeaders(url)).to.deep.equal({});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('stripCustomRpcHeaders', () => {
|
|
36
|
+
it('strips custom_rpc_header and returns clean URL with headers', () => {
|
|
37
|
+
const url = 'https://tron-mainnet.gateway.tatum.io/jsonrpc?custom_rpc_header=x-api-key:abc123';
|
|
38
|
+
const result = stripCustomRpcHeaders(url);
|
|
39
|
+
expect(result.url).to.equal('https://tron-mainnet.gateway.tatum.io/jsonrpc');
|
|
40
|
+
expect(result.headers).to.deep.equal({ 'x-api-key': 'abc123' });
|
|
41
|
+
});
|
|
42
|
+
it('preserves non-custom_rpc_header query params', () => {
|
|
43
|
+
const url = 'https://host/jsonrpc?custom_rpc_header=x-api-key:abc&other=1';
|
|
44
|
+
const result = stripCustomRpcHeaders(url);
|
|
45
|
+
expect(result.url).to.equal('https://host/jsonrpc?other=1');
|
|
46
|
+
expect(result.headers).to.deep.equal({ 'x-api-key': 'abc' });
|
|
47
|
+
});
|
|
48
|
+
it('returns original URL unchanged when no custom_rpc_header', () => {
|
|
49
|
+
const url = 'https://api.trongrid.io/jsonrpc';
|
|
50
|
+
const result = stripCustomRpcHeaders(url);
|
|
51
|
+
expect(result.url).to.equal(url);
|
|
52
|
+
expect(result.headers).to.deep.equal({});
|
|
53
|
+
});
|
|
54
|
+
it('returns original URL unchanged when xApiKey query param is used', () => {
|
|
55
|
+
const url = 'https://tron-mainnet.gateway.tatum.io/jsonrpc?xApiKey=abc123';
|
|
56
|
+
const result = stripCustomRpcHeaders(url);
|
|
57
|
+
expect(result.url).to.equal(url);
|
|
58
|
+
expect(result.headers).to.deep.equal({});
|
|
59
|
+
});
|
|
60
|
+
it('strips malformed custom_rpc_header without colon', () => {
|
|
61
|
+
const url = 'https://host/jsonrpc?custom_rpc_header=nocolon';
|
|
62
|
+
const result = stripCustomRpcHeaders(url);
|
|
63
|
+
expect(result.url).to.equal('https://host/jsonrpc');
|
|
64
|
+
expect(result.headers).to.deep.equal({});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe('toHttpApiUrl', () => {
|
|
68
|
+
it('strips a trailing /jsonrpc path', () => {
|
|
69
|
+
expect(toHttpApiUrl('https://node.example.com:8090/jsonrpc')).to.equal('https://node.example.com:8090/');
|
|
70
|
+
});
|
|
71
|
+
it('strips custom_rpc_header query params', () => {
|
|
72
|
+
expect(toHttpApiUrl('https://node.example.com/jsonrpc?custom_rpc_header=x-api-key:abc')).to.equal('https://node.example.com/');
|
|
73
|
+
});
|
|
74
|
+
it('preserves a private/custom host', () => {
|
|
75
|
+
const result = toHttpApiUrl('https://my-tron-node.example.com/jsonrpc');
|
|
76
|
+
expect(result).to.contain('my-tron-node.example.com');
|
|
77
|
+
expect(result).to.not.contain('trongrid');
|
|
78
|
+
});
|
|
79
|
+
it('leaves a plain host without /jsonrpc unchanged', () => {
|
|
80
|
+
expect(toHttpApiUrl('https://node.example.com')).to.equal('https://node.example.com/');
|
|
81
|
+
});
|
|
82
|
+
it('returns a trongrid host as its own host', () => {
|
|
83
|
+
const result = toHttpApiUrl('https://api.trongrid.io/jsonrpc');
|
|
84
|
+
expect(result).to.contain('trongrid');
|
|
85
|
+
});
|
|
86
|
+
it('preserves non-custom_rpc_header query params', () => {
|
|
87
|
+
expect(toHttpApiUrl('https://host.example.com/jsonrpc?custom_rpc_header=x-api-key:abc&foo=bar')).to.equal('https://host.example.com/?foo=bar');
|
|
88
|
+
});
|
|
89
|
+
it('leaves a non-trailing /jsonrpc path segment intact', () => {
|
|
90
|
+
expect(toHttpApiUrl('https://host.example.com/jsonrpc/v1')).to.equal('https://host.example.com/jsonrpc/v1');
|
|
91
|
+
});
|
|
92
|
+
it('throws on invalid (non-URL) input', () => {
|
|
93
|
+
expect(() => toHttpApiUrl('not-a-url')).to.throw();
|
|
94
|
+
});
|
|
95
|
+
// Provider-style URLs that carry the API key in the path (e.g. Alchemy:
|
|
96
|
+
// https://tron-mainnet.g.alchemy.com/v2/<key>) must keep the host and path
|
|
97
|
+
// verbatim, since the provider serves both eth JSON-RPC and the Tron HTTP API
|
|
98
|
+
// under that base. A generic host is used here to avoid secret scanners.
|
|
99
|
+
it('preserves a provider base URL with an api-key path segment (no /jsonrpc)', () => {
|
|
100
|
+
expect(toHttpApiUrl('https://tron-rpc.example.com/v2/API_KEY')).to.equal('https://tron-rpc.example.com/v2/API_KEY');
|
|
101
|
+
});
|
|
102
|
+
it('strips only a trailing /jsonrpc from such a provider URL', () => {
|
|
103
|
+
expect(toHttpApiUrl('https://tron-rpc.example.com/v2/API_KEY/jsonrpc')).to.equal('https://tron-rpc.example.com/v2/API_KEY');
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
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,CAAC,qCAAqC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAClE,qCAAqC,CACtC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,wEAAwE;IACxE,2EAA2E;IAC3E,8EAA8E;IAC9E,yEAAyE;IACzE,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;QAClF,MAAM,CAAC,YAAY,CAAC,yCAAyC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CACtE,yCAAyC,CAC1C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,CACJ,YAAY,CAAC,iDAAiD,CAAC,CAChE,CAAC,EAAE,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factories/index.ts"],"names":[],"mappings":"AAMA,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Re-export all typechain types and factories (flattened).
|
|
2
|
+
// These factories are generated from the same Solidity source as @recoillink/core
|
|
3
|
+
// via the tron-solc compiler. They have identical ABIs and deploy signatures, differing
|
|
4
|
+
// only in bytecode (TVM-compiled with 0x41 Create2 prefix). This 1:1 correspondence
|
|
5
|
+
// with core factory class names is relied upon by the SDK's MultiProvider.handleDeploy
|
|
6
|
+
// to dynamically resolve the correct factory at deploy time.
|
|
7
|
+
export * from '@recoillink/core/tron/typechain';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/factories/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,kFAAkF;AAClF,wFAAwF;AACxF,oFAAoF;AACpF,uFAAuF;AACvF,6DAA6D;AAC7D,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TronWeb } from 'tronweb';
|
|
2
|
+
import { TronHookTypes } from '../utils/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Type alias for query client with ISM extension.
|
|
5
|
+
* Used throughout ISM readers to ensure type safety.
|
|
6
|
+
*/
|
|
7
|
+
export type TronHookQueryClient = TronWeb;
|
|
8
|
+
export declare function getHookType(query: TronHookQueryClient, hookAddress: string): Promise<TronHookTypes>;
|
|
9
|
+
/**
|
|
10
|
+
* Query IGP hook configuration from chain.
|
|
11
|
+
*
|
|
12
|
+
* @param query - Query client with PostDispatchExtension
|
|
13
|
+
* @param hookId - ID of the IGP hook to query
|
|
14
|
+
* @returns IGP hook configuration with address, owner, and destination gas configs
|
|
15
|
+
* @throws Error if IGP hook not found
|
|
16
|
+
*/
|
|
17
|
+
export declare function getIgpHookConfig(query: TronHookQueryClient, hookId: string): Promise<{
|
|
18
|
+
address: string;
|
|
19
|
+
owner: string;
|
|
20
|
+
destinationGasConfigs: {
|
|
21
|
+
[domainId: string]: {
|
|
22
|
+
gasOracle: {
|
|
23
|
+
tokenExchangeRate: string;
|
|
24
|
+
gasPrice: string;
|
|
25
|
+
};
|
|
26
|
+
gasOverhead: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Query MerkleTree hook configuration from chain.
|
|
32
|
+
*
|
|
33
|
+
* @param query - Query client with PostDispatchExtension
|
|
34
|
+
* @param hookId - ID of the MerkleTree hook to query
|
|
35
|
+
* @returns MerkleTree hook configuration with address
|
|
36
|
+
* @throws Error if MerkleTree hook not found
|
|
37
|
+
*/
|
|
38
|
+
export declare function getMerkleTreeHookConfig(query: TronHookQueryClient, hookId: string): Promise<{
|
|
39
|
+
address: string;
|
|
40
|
+
}>;
|
|
41
|
+
//# sourceMappingURL=hook-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-query.d.ts","sourceRoot":"","sources":["../../src/hook/hook-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAQlC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAE1C,wBAAsB,WAAW,CAC/B,KAAK,EAAE,mBAAmB,EAC1B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,CAAC,CAaxB;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB,EAAE;QACrB,CAAC,QAAQ,EAAE,MAAM,GAAG;YAClB,SAAS,EAAE;gBACT,iBAAiB,EAAE,MAAM,CAAC;gBAC1B,QAAQ,EAAE,MAAM,CAAC;aAClB,CAAC;YACF,WAAW,EAAE,MAAM,CAAC;SACrB,CAAC;KACH,CAAC;CACH,CAAC,CAqDD;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAeD"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { assert } from '@recoillink/utils';
|
|
2
|
+
import IPostDispatchHookAbi from '@recoillink/core/tron/abi/contracts/interfaces/hooks/IPostDispatchHook.sol/IPostDispatchHook.json' with { type: 'json' };
|
|
3
|
+
import InterchainGasPaymasterAbi from '@recoillink/core/tron/abi/contracts/hooks/igp/InterchainGasPaymaster.sol/InterchainGasPaymaster.json' with { type: 'json' };
|
|
4
|
+
import MerkleTreeHookAbi from '@recoillink/core/tron/abi/contracts/hooks/MerkleTreeHook.sol/MerkleTreeHook.json' with { type: 'json' };
|
|
5
|
+
import StorageGasOracleAbi from '@recoillink/core/tron/abi/contracts/hooks/igp/StorageGasOracle.sol/StorageGasOracle.json' with { type: 'json' };
|
|
6
|
+
import { TronHookTypes } from '../utils/types.js';
|
|
7
|
+
export async function getHookType(query, hookAddress) {
|
|
8
|
+
const contract = query.contract(IPostDispatchHookAbi.abi, hookAddress);
|
|
9
|
+
const hookType = Number(await contract.hookType().call());
|
|
10
|
+
switch (hookType) {
|
|
11
|
+
case 3:
|
|
12
|
+
return TronHookTypes.MERKLE_TREE;
|
|
13
|
+
case 4:
|
|
14
|
+
return TronHookTypes.INTERCHAIN_GAS_PAYMASTER;
|
|
15
|
+
default:
|
|
16
|
+
throw new Error(`Unknown Hook type for address: ${hookAddress}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Query IGP hook configuration from chain.
|
|
21
|
+
*
|
|
22
|
+
* @param query - Query client with PostDispatchExtension
|
|
23
|
+
* @param hookId - ID of the IGP hook to query
|
|
24
|
+
* @returns IGP hook configuration with address, owner, and destination gas configs
|
|
25
|
+
* @throws Error if IGP hook not found
|
|
26
|
+
*/
|
|
27
|
+
export async function getIgpHookConfig(query, hookId) {
|
|
28
|
+
try {
|
|
29
|
+
const igp = query.contract(InterchainGasPaymasterAbi.abi, hookId);
|
|
30
|
+
const hookType = await igp.hookType().call();
|
|
31
|
+
assert(Number(hookType) === 4, `hook type does not equal INTERCHAIN_GAS_PAYMASTER`);
|
|
32
|
+
const domainIds = await igp.domains().call();
|
|
33
|
+
const destinationGasConfigs = {};
|
|
34
|
+
for (const domainId of domainIds) {
|
|
35
|
+
const c = await igp.destinationGasConfigs(domainId).call();
|
|
36
|
+
const gasOracle = query.contract(StorageGasOracleAbi.abi, query.address.fromHex(c.gasOracle));
|
|
37
|
+
const { tokenExchangeRate, gasPrice } = await gasOracle
|
|
38
|
+
.remoteGasData(domainId)
|
|
39
|
+
.call();
|
|
40
|
+
destinationGasConfigs[domainId.toString()] = {
|
|
41
|
+
gasOracle: {
|
|
42
|
+
tokenExchangeRate: tokenExchangeRate.toString(),
|
|
43
|
+
gasPrice: gasPrice.toString(),
|
|
44
|
+
},
|
|
45
|
+
gasOverhead: c.gasOverhead.toString(),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
address: hookId,
|
|
50
|
+
owner: query.address.fromHex(await igp.owner().call()),
|
|
51
|
+
destinationGasConfigs,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw new Error(`Failed to query IGP hook config at ${hookId}: ${error.message}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Query MerkleTree hook configuration from chain.
|
|
60
|
+
*
|
|
61
|
+
* @param query - Query client with PostDispatchExtension
|
|
62
|
+
* @param hookId - ID of the MerkleTree hook to query
|
|
63
|
+
* @returns MerkleTree hook configuration with address
|
|
64
|
+
* @throws Error if MerkleTree hook not found
|
|
65
|
+
*/
|
|
66
|
+
export async function getMerkleTreeHookConfig(query, hookId) {
|
|
67
|
+
try {
|
|
68
|
+
const contract = query.contract(MerkleTreeHookAbi.abi, hookId);
|
|
69
|
+
const hookType = await contract.hookType().call();
|
|
70
|
+
assert(Number(hookType) === 3, `hook type does not equal MERKLE_TREE`);
|
|
71
|
+
return {
|
|
72
|
+
address: hookId,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
throw new Error(`Failed to query MerkleTree hook config at ${hookId}: ${error.message}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=hook-query.js.map
|
|
@@ -0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C;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,KAA0B,EAC1B,MAAc;IAId,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAE/D,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,sCAAsC,CAAC,CAAC;QAEvE,OAAO;YACL,OAAO,EAAE,MAAM;SAChB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,6CAA6C,MAAM,KAAM,KAAe,CAAC,OAAO,EAAE,CACnF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TronWeb } from 'tronweb';
|
|
2
|
+
import { TronTransaction } from '../utils/types.js';
|
|
3
|
+
export declare function getCreateMerkleTreeHookTx(tronweb: Readonly<TronWeb>, fromAddress: string, mailboxAddress: string): Promise<TronTransaction>;
|
|
4
|
+
export declare function getCreateIgpTx(tronweb: Readonly<TronWeb>, fromAddress: string): Promise<TronTransaction>;
|
|
5
|
+
export declare function getCreateProxyTx(tronweb: Readonly<TronWeb>, fromAddress: string, implAddress: string, proxyAdminAddress: string): Promise<TronTransaction>;
|
|
6
|
+
export declare function getInitIgpTx(tronweb: Readonly<TronWeb>, fromAddress: string, config: {
|
|
7
|
+
igpAddress: string;
|
|
8
|
+
}): Promise<TronTransaction>;
|
|
9
|
+
export declare function getCreateOracleTx(tronweb: Readonly<TronWeb>, fromAddress: string): Promise<TronTransaction>;
|
|
10
|
+
export declare function getSetOracleTx(tronweb: Readonly<TronWeb>, fromAddress: string, config: {
|
|
11
|
+
igpAddress: string;
|
|
12
|
+
oracleAddress: string;
|
|
13
|
+
}): Promise<TronTransaction>;
|
|
14
|
+
export declare function getSetRemoteGasTx(tronweb: Readonly<TronWeb>, fromAddress: string, config: {
|
|
15
|
+
igpAddress: string;
|
|
16
|
+
destinationGasConfigs: {
|
|
17
|
+
remoteDomainId: number;
|
|
18
|
+
gasOracle: {
|
|
19
|
+
tokenExchangeRate: string;
|
|
20
|
+
gasPrice: string;
|
|
21
|
+
};
|
|
22
|
+
}[];
|
|
23
|
+
}): Promise<TronTransaction>;
|
|
24
|
+
export declare function getSetIgpOwnerTx(tronweb: Readonly<TronWeb>, fromAddress: string, config: {
|
|
25
|
+
igpAddress: string;
|
|
26
|
+
newOwner: string;
|
|
27
|
+
}): Promise<TronTransaction>;
|
|
28
|
+
export declare function getSetIgpDestinationGasConfigTx(tronweb: Readonly<TronWeb>, fromAddress: string, config: {
|
|
29
|
+
igpAddress: string;
|
|
30
|
+
destinationGasConfigs: {
|
|
31
|
+
remoteDomainId: number;
|
|
32
|
+
gasOverhead: string;
|
|
33
|
+
}[];
|
|
34
|
+
}): Promise<TronTransaction>;
|
|
35
|
+
export declare function getRemoveIgpDestinationGasConfigTx(tronweb: Readonly<TronWeb>, fromAddress: string, config: {
|
|
36
|
+
igpAddress: string;
|
|
37
|
+
remoteDomainIds: number[];
|
|
38
|
+
}): Promise<TronTransaction>;
|
|
39
|
+
//# sourceMappingURL=hook-tx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-tx.d.ts","sourceRoot":"","sources":["../../src/hook/hook-tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AASlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,eAAe,CAAC,CAI1B;AAED,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AE,MAAM,EACnB,MAAM,EAAE;IACN,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,GACA,OAAO,CAAC,eAAe,CAAC,CAe1B;AAED,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE;IACN,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,EAAE;QACrB,cAAc,EAAE,MAAM,CAAC;QACvB,WAAW,EAAE,MAAM,CAAC;KACrB,EAAE,CAAC;CACL,GACA,OAAO,CAAC,eAAe,CAAC,CAkC1B;AAED,wBAAsB,kCAAkC,CACtD,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE;IACN,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,GACA,OAAO,CAAC,eAAe,CAAC,CAe1B"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { assert } from '@recoillink/utils';
|
|
2
|
+
import InterchainGasPaymasterAbi from '@recoillink/core/tron/abi/contracts/hooks/igp/InterchainGasPaymaster.sol/InterchainGasPaymaster.json' with { type: 'json' };
|
|
3
|
+
import MerkleTreeHookAbi from '@recoillink/core/tron/abi/contracts/hooks/MerkleTreeHook.sol/MerkleTreeHook.json' with { type: 'json' };
|
|
4
|
+
import StorageGasOracleAbi from '@recoillink/core/tron/abi/contracts/hooks/igp/StorageGasOracle.sol/StorageGasOracle.json' with { type: 'json' };
|
|
5
|
+
import TransparentUpgradeableProxyAbi from '@recoillink/core/tron/abi/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json' with { type: 'json' };
|
|
6
|
+
import { createDeploymentTransaction } from '../utils/index.js';
|
|
7
|
+
export async function getCreateMerkleTreeHookTx(tronweb, fromAddress, mailboxAddress) {
|
|
8
|
+
return createDeploymentTransaction(tronweb, MerkleTreeHookAbi, fromAddress, [
|
|
9
|
+
mailboxAddress,
|
|
10
|
+
]);
|
|
11
|
+
}
|
|
12
|
+
export async function getCreateIgpTx(tronweb, fromAddress) {
|
|
13
|
+
return createDeploymentTransaction(tronweb, InterchainGasPaymasterAbi, fromAddress, []);
|
|
14
|
+
}
|
|
15
|
+
export async function getCreateProxyTx(tronweb, fromAddress, implAddress, proxyAdminAddress) {
|
|
16
|
+
return createDeploymentTransaction(tronweb, TransparentUpgradeableProxyAbi, fromAddress, [implAddress, proxyAdminAddress, '0x']);
|
|
17
|
+
}
|
|
18
|
+
export async function getInitIgpTx(tronweb, fromAddress, config) {
|
|
19
|
+
const { transaction } = await tronweb.transactionBuilder.triggerSmartContract(config.igpAddress, 'initialize(address,address)', {}, [
|
|
20
|
+
{
|
|
21
|
+
type: 'address',
|
|
22
|
+
value: fromAddress,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: 'address',
|
|
26
|
+
value: fromAddress,
|
|
27
|
+
},
|
|
28
|
+
], tronweb.address.toHex(fromAddress));
|
|
29
|
+
return transaction;
|
|
30
|
+
}
|
|
31
|
+
export async function getCreateOracleTx(tronweb, fromAddress) {
|
|
32
|
+
return createDeploymentTransaction(tronweb, StorageGasOracleAbi, fromAddress, []);
|
|
33
|
+
}
|
|
34
|
+
export async function getSetOracleTx(tronweb, fromAddress, config) {
|
|
35
|
+
const { transaction } = await tronweb.transactionBuilder.triggerSmartContract(config.igpAddress, 'setGasOracle(address)', {}, [
|
|
36
|
+
{
|
|
37
|
+
type: 'address',
|
|
38
|
+
value: config.oracleAddress,
|
|
39
|
+
},
|
|
40
|
+
], tronweb.address.toHex(fromAddress));
|
|
41
|
+
return transaction;
|
|
42
|
+
}
|
|
43
|
+
export async function getSetRemoteGasTx(tronweb, fromAddress, config) {
|
|
44
|
+
const igp = tronweb.contract(InterchainGasPaymasterAbi.abi, config.igpAddress);
|
|
45
|
+
const oracleAddress = tronweb.address.fromHex(await igp.gasOracle().call());
|
|
46
|
+
const { transaction } = await tronweb.transactionBuilder.triggerSmartContract(oracleAddress, 'setRemoteGasDataConfigs((uint32,uint128,uint128)[])', {}, [
|
|
47
|
+
{
|
|
48
|
+
type: 'tuple(uint32 remoteDomain, uint128 tokenExchangeRate, uint128 gasPrice)[]',
|
|
49
|
+
value: config.destinationGasConfigs.map((c) => ({
|
|
50
|
+
remoteDomain: c.remoteDomainId,
|
|
51
|
+
tokenExchangeRate: c.gasOracle.tokenExchangeRate,
|
|
52
|
+
gasPrice: c.gasOracle.gasPrice,
|
|
53
|
+
})),
|
|
54
|
+
},
|
|
55
|
+
], tronweb.address.toHex(fromAddress));
|
|
56
|
+
return transaction;
|
|
57
|
+
}
|
|
58
|
+
export async function getSetIgpOwnerTx(tronweb, fromAddress, config) {
|
|
59
|
+
const { transaction } = await tronweb.transactionBuilder.triggerSmartContract(config.igpAddress, 'transferOwnership(address)', {}, [
|
|
60
|
+
{
|
|
61
|
+
type: 'address',
|
|
62
|
+
value: config.newOwner,
|
|
63
|
+
},
|
|
64
|
+
], tronweb.address.toHex(fromAddress));
|
|
65
|
+
return transaction;
|
|
66
|
+
}
|
|
67
|
+
export async function getSetIgpDestinationGasConfigTx(tronweb, fromAddress, config) {
|
|
68
|
+
const igp = tronweb.contract(InterchainGasPaymasterAbi.abi, config.igpAddress);
|
|
69
|
+
const hookType = await igp.hookType().call();
|
|
70
|
+
assert(Number(hookType) === 4, `hook type does not equal INTERCHAIN_GAS_PAYMASTER`);
|
|
71
|
+
const gasOracle = await igp.gasOracle().call();
|
|
72
|
+
const { transaction } = await tronweb.transactionBuilder.triggerSmartContract(config.igpAddress, 'setDestinationGasConfigs((uint32,(address,uint96))[])', {}, [
|
|
73
|
+
{
|
|
74
|
+
type: 'tuple(uint32 remoteDomain, tuple(address gasOracle, uint96 gasOverhead) config)[]',
|
|
75
|
+
value: config.destinationGasConfigs.map((c) => ({
|
|
76
|
+
remoteDomain: c.remoteDomainId,
|
|
77
|
+
config: {
|
|
78
|
+
gasOracle: gasOracle.replace('41', '0x'), // tron address format requires 0x prefix here
|
|
79
|
+
gasOverhead: c.gasOverhead,
|
|
80
|
+
},
|
|
81
|
+
})),
|
|
82
|
+
},
|
|
83
|
+
], tronweb.address.toHex(fromAddress));
|
|
84
|
+
return transaction;
|
|
85
|
+
}
|
|
86
|
+
export async function getRemoveIgpDestinationGasConfigTx(tronweb, fromAddress, config) {
|
|
87
|
+
const { transaction } = await tronweb.transactionBuilder.triggerSmartContract(config.igpAddress, 'removeDestinationGasConfigs(uint32[])', {}, [
|
|
88
|
+
{
|
|
89
|
+
type: 'uint32[]',
|
|
90
|
+
value: config.remoteDomainIds,
|
|
91
|
+
},
|
|
92
|
+
], tronweb.address.toHex(fromAddress));
|
|
93
|
+
return transaction;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=hook-tx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-tx.js","sourceRoot":"","sources":["../../src/hook/hook-tx.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,yBAAyB,MAAM,sGAAsG,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACnK,OAAO,iBAAiB,MAAM,kFAAkF,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACvI,OAAO,mBAAmB,MAAM,0FAA0F,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACjJ,OAAO,8BAA8B,MAAM,sIAAsI,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACxM,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAGhE,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,OAA0B,EAC1B,WAAmB,EACnB,cAAsB;IAEtB,OAAO,2BAA2B,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE;QAC1E,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GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,oBAAoB,CAC3E,MAAM,CAAC,UAAU,EACjB,uCAAuC,EACvC,EAAE,EACF;QACE;YACE,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,MAAM,CAAC,eAAe;SAC9B;KACF,EACD,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CACnC,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './ethers/index.js';
|
|
2
|
+
export * from './factories/index.js';
|
|
3
|
+
export { TronProvider } from './clients/provider.js';
|
|
4
|
+
export { TronSigner } from './clients/signer.js';
|
|
5
|
+
export { TronProtocolProvider } from './clients/protocol.js';
|
|
6
|
+
export { TronReceipt } from './utils/types.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAGlC,cAAc,sBAAsB,CAAC;AAGrC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Ethers-compatible adapters (primary interface)
|
|
2
|
+
export * from './ethers/index.js';
|
|
3
|
+
// Contract factories (typechain re-exports)
|
|
4
|
+
export * from './factories/index.js';
|
|
5
|
+
// AltVM clients (provider-sdk pattern)
|
|
6
|
+
export { TronProvider } from './clients/provider.js';
|
|
7
|
+
export { TronSigner } from './clients/signer.js';
|
|
8
|
+
export { TronProtocolProvider } from './clients/protocol.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,cAAc,mBAAmB,CAAC;AAElC,4CAA4C;AAC5C,cAAc,sBAAsB,CAAC;AAErC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { TronWeb } from 'tronweb';
|
|
2
|
+
import { TronIsmTypes } from '../utils/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Type alias for query client with ISM extension.
|
|
5
|
+
* Used throughout ISM readers to ensure type safety.
|
|
6
|
+
*/
|
|
7
|
+
export type TronIsmQueryClient = TronWeb;
|
|
8
|
+
/**
|
|
9
|
+
* Query ISM type from address.
|
|
10
|
+
*
|
|
11
|
+
* @param query - Query client
|
|
12
|
+
* @param ismAddress - Address of the ISM to query
|
|
13
|
+
* @returns The AltVM ISM type
|
|
14
|
+
* @throws Error if ISM not found or unknown type
|
|
15
|
+
*/
|
|
16
|
+
export declare function getIsmType(query: TronIsmQueryClient, ismAddress: string): Promise<TronIsmTypes>;
|
|
17
|
+
/**
|
|
18
|
+
* Query NoopIsm configuration.
|
|
19
|
+
*
|
|
20
|
+
* @param query - Query client
|
|
21
|
+
* @param ismAddress - Address of the NoopIsm to query
|
|
22
|
+
* @returns NoopIsm configuration with address
|
|
23
|
+
* @throws Error if NoopIsm not found
|
|
24
|
+
*/
|
|
25
|
+
export declare function getNoopIsmConfig(query: TronIsmQueryClient, ismAddress: string): Promise<{
|
|
26
|
+
address: string;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Query Message ID Multisig ISM configuration.
|
|
30
|
+
*
|
|
31
|
+
* @param query - Query client
|
|
32
|
+
* @param ismAddress - Address of the Message ID Multisig ISM to query
|
|
33
|
+
* @returns Message ID Multisig ISM configuration with address, validators, and threshold
|
|
34
|
+
* @throws Error if Message ID Multisig ISM not found
|
|
35
|
+
*/
|
|
36
|
+
export declare function getMessageIdMultisigIsmConfig(query: TronIsmQueryClient, ismAddress: string): Promise<{
|
|
37
|
+
address: string;
|
|
38
|
+
validators: string[];
|
|
39
|
+
threshold: number;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Query Merkle Root Multisig ISM configuration.
|
|
43
|
+
*
|
|
44
|
+
* @param query - Query client
|
|
45
|
+
* @param ismAddress - Address of the Merkle Root Multisig ISM to query
|
|
46
|
+
* @returns Merkle Root Multisig ISM configuration with address, validators, and threshold
|
|
47
|
+
* @throws Error if Merkle Root Multisig ISM not found
|
|
48
|
+
*/
|
|
49
|
+
export declare function getMerkleRootMultisigIsmConfig(query: TronIsmQueryClient, ismAddress: string): Promise<{
|
|
50
|
+
address: string;
|
|
51
|
+
validators: string[];
|
|
52
|
+
threshold: number;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Query routing ISM configuration.
|
|
56
|
+
*
|
|
57
|
+
* @param query - Query client
|
|
58
|
+
* @param ismAddress - Address of the routing ISM to query
|
|
59
|
+
* @returns Routing ISM configuration with address, owner, and routes
|
|
60
|
+
* @throws Error if routing ISM not found
|
|
61
|
+
*/
|
|
62
|
+
export declare function getRoutingIsmConfig(query: TronIsmQueryClient, ismAddress: string): Promise<{
|
|
63
|
+
address: string;
|
|
64
|
+
owner: string;
|
|
65
|
+
routes: Array<{
|
|
66
|
+
domainId: number;
|
|
67
|
+
ismAddress: string;
|
|
68
|
+
}>;
|
|
69
|
+
}>;
|
|
70
|
+
//# sourceMappingURL=ism-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ism-query.d.ts","sourceRoot":"","sources":["../../src/ism/ism-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