@gearbox-protocol/sdk 14.11.0-next.2 → 14.11.0-next.3
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/cjs/dev/index.js
CHANGED
|
@@ -44,6 +44,7 @@ __reExport(dev_exports, require("./replaceStorage.js"), module.exports);
|
|
|
44
44
|
__reExport(dev_exports, require("./resilientTransport.js"), module.exports);
|
|
45
45
|
__reExport(dev_exports, require("./transports.js"), module.exports);
|
|
46
46
|
__reExport(dev_exports, require("./types.js"), module.exports);
|
|
47
|
+
__reExport(dev_exports, require("./verifyTestnet.js"), module.exports);
|
|
47
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
49
|
0 && (module.exports = {
|
|
49
50
|
isRangeError,
|
|
@@ -67,5 +68,6 @@ __reExport(dev_exports, require("./types.js"), module.exports);
|
|
|
67
68
|
...require("./replaceStorage.js"),
|
|
68
69
|
...require("./resilientTransport.js"),
|
|
69
70
|
...require("./transports.js"),
|
|
70
|
-
...require("./types.js")
|
|
71
|
+
...require("./types.js"),
|
|
72
|
+
...require("./verifyTestnet.js")
|
|
71
73
|
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var verifyTestnet_exports = {};
|
|
20
|
+
__export(verifyTestnet_exports, {
|
|
21
|
+
ONCHAIN_EXECUTION_ID_ADDRESS: () => ONCHAIN_EXECUTION_ID_ADDRESS,
|
|
22
|
+
iOnchainExecutionIdAbi: () => iOnchainExecutionIdAbi,
|
|
23
|
+
verifyTestnet: () => verifyTestnet
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(verifyTestnet_exports);
|
|
26
|
+
const ONCHAIN_EXECUTION_ID_ADDRESS = "0x34131bc13eaa4ef5f98c2a423f93bc88d6ee01ba";
|
|
27
|
+
const iOnchainExecutionIdAbi = [
|
|
28
|
+
{
|
|
29
|
+
type: "function",
|
|
30
|
+
name: "deployer",
|
|
31
|
+
inputs: [],
|
|
32
|
+
outputs: [
|
|
33
|
+
{
|
|
34
|
+
name: "",
|
|
35
|
+
type: "string",
|
|
36
|
+
internalType: "string"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
stateMutability: "view"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "function",
|
|
43
|
+
name: "executionId",
|
|
44
|
+
inputs: [],
|
|
45
|
+
outputs: [
|
|
46
|
+
{
|
|
47
|
+
name: "",
|
|
48
|
+
type: "string",
|
|
49
|
+
internalType: "string"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
stateMutability: "view"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: "function",
|
|
56
|
+
name: "forkAlias",
|
|
57
|
+
inputs: [],
|
|
58
|
+
outputs: [
|
|
59
|
+
{
|
|
60
|
+
name: "",
|
|
61
|
+
type: "string",
|
|
62
|
+
internalType: "string"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
stateMutability: "view"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: "function",
|
|
69
|
+
name: "info",
|
|
70
|
+
inputs: [],
|
|
71
|
+
outputs: [
|
|
72
|
+
{
|
|
73
|
+
name: "",
|
|
74
|
+
type: "tuple",
|
|
75
|
+
internalType: "struct ExecutionId.Info",
|
|
76
|
+
components: [
|
|
77
|
+
{
|
|
78
|
+
name: "deployer",
|
|
79
|
+
type: "string",
|
|
80
|
+
internalType: "string"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "executionId",
|
|
84
|
+
type: "string",
|
|
85
|
+
internalType: "string"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "forkAlias",
|
|
89
|
+
type: "string",
|
|
90
|
+
internalType: "string"
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
stateMutability: "view"
|
|
96
|
+
}
|
|
97
|
+
];
|
|
98
|
+
async function verifyTestnet(client, expected) {
|
|
99
|
+
try {
|
|
100
|
+
const { deployer, executionId, forkAlias } = await client.readContract({
|
|
101
|
+
abi: iOnchainExecutionIdAbi,
|
|
102
|
+
address: ONCHAIN_EXECUTION_ID_ADDRESS,
|
|
103
|
+
functionName: "info"
|
|
104
|
+
});
|
|
105
|
+
if (deployer !== "anvil-manager") {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if ("executionId" in expected && expected.executionId && expected.executionId !== executionId) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if ("alias" in expected && expected.alias && expected.alias !== forkAlias) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
} catch {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
120
|
+
0 && (module.exports = {
|
|
121
|
+
ONCHAIN_EXECUTION_ID_ADDRESS,
|
|
122
|
+
iOnchainExecutionIdAbi,
|
|
123
|
+
verifyTestnet
|
|
124
|
+
});
|
package/dist/esm/dev/index.js
CHANGED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const ONCHAIN_EXECUTION_ID_ADDRESS = "0x34131bc13eaa4ef5f98c2a423f93bc88d6ee01ba";
|
|
2
|
+
const iOnchainExecutionIdAbi = [
|
|
3
|
+
{
|
|
4
|
+
type: "function",
|
|
5
|
+
name: "deployer",
|
|
6
|
+
inputs: [],
|
|
7
|
+
outputs: [
|
|
8
|
+
{
|
|
9
|
+
name: "",
|
|
10
|
+
type: "string",
|
|
11
|
+
internalType: "string"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
stateMutability: "view"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: "function",
|
|
18
|
+
name: "executionId",
|
|
19
|
+
inputs: [],
|
|
20
|
+
outputs: [
|
|
21
|
+
{
|
|
22
|
+
name: "",
|
|
23
|
+
type: "string",
|
|
24
|
+
internalType: "string"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
stateMutability: "view"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: "function",
|
|
31
|
+
name: "forkAlias",
|
|
32
|
+
inputs: [],
|
|
33
|
+
outputs: [
|
|
34
|
+
{
|
|
35
|
+
name: "",
|
|
36
|
+
type: "string",
|
|
37
|
+
internalType: "string"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
stateMutability: "view"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "function",
|
|
44
|
+
name: "info",
|
|
45
|
+
inputs: [],
|
|
46
|
+
outputs: [
|
|
47
|
+
{
|
|
48
|
+
name: "",
|
|
49
|
+
type: "tuple",
|
|
50
|
+
internalType: "struct ExecutionId.Info",
|
|
51
|
+
components: [
|
|
52
|
+
{
|
|
53
|
+
name: "deployer",
|
|
54
|
+
type: "string",
|
|
55
|
+
internalType: "string"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "executionId",
|
|
59
|
+
type: "string",
|
|
60
|
+
internalType: "string"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "forkAlias",
|
|
64
|
+
type: "string",
|
|
65
|
+
internalType: "string"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
stateMutability: "view"
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
async function verifyTestnet(client, expected) {
|
|
74
|
+
try {
|
|
75
|
+
const { deployer, executionId, forkAlias } = await client.readContract({
|
|
76
|
+
abi: iOnchainExecutionIdAbi,
|
|
77
|
+
address: ONCHAIN_EXECUTION_ID_ADDRESS,
|
|
78
|
+
functionName: "info"
|
|
79
|
+
});
|
|
80
|
+
if (deployer !== "anvil-manager") {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if ("executionId" in expected && expected.executionId && expected.executionId !== executionId) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if ("alias" in expected && expected.alias && expected.alias !== forkAlias) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
} catch {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
ONCHAIN_EXECUTION_ID_ADDRESS,
|
|
96
|
+
iOnchainExecutionIdAbi,
|
|
97
|
+
verifyTestnet
|
|
98
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Address, PublicClient } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Address is stable, contract deployed via create2
|
|
4
|
+
*/
|
|
5
|
+
export declare const ONCHAIN_EXECUTION_ID_ADDRESS: Address;
|
|
6
|
+
/**
|
|
7
|
+
* This contract is deployed on every Gearbox testnet and contains
|
|
8
|
+
* execution id and alias of the testnet
|
|
9
|
+
*/
|
|
10
|
+
export declare const iOnchainExecutionIdAbi: readonly [{
|
|
11
|
+
readonly type: "function";
|
|
12
|
+
readonly name: "deployer";
|
|
13
|
+
readonly inputs: readonly [];
|
|
14
|
+
readonly outputs: readonly [{
|
|
15
|
+
readonly name: "";
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
readonly internalType: "string";
|
|
18
|
+
}];
|
|
19
|
+
readonly stateMutability: "view";
|
|
20
|
+
}, {
|
|
21
|
+
readonly type: "function";
|
|
22
|
+
readonly name: "executionId";
|
|
23
|
+
readonly inputs: readonly [];
|
|
24
|
+
readonly outputs: readonly [{
|
|
25
|
+
readonly name: "";
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly internalType: "string";
|
|
28
|
+
}];
|
|
29
|
+
readonly stateMutability: "view";
|
|
30
|
+
}, {
|
|
31
|
+
readonly type: "function";
|
|
32
|
+
readonly name: "forkAlias";
|
|
33
|
+
readonly inputs: readonly [];
|
|
34
|
+
readonly outputs: readonly [{
|
|
35
|
+
readonly name: "";
|
|
36
|
+
readonly type: "string";
|
|
37
|
+
readonly internalType: "string";
|
|
38
|
+
}];
|
|
39
|
+
readonly stateMutability: "view";
|
|
40
|
+
}, {
|
|
41
|
+
readonly type: "function";
|
|
42
|
+
readonly name: "info";
|
|
43
|
+
readonly inputs: readonly [];
|
|
44
|
+
readonly outputs: readonly [{
|
|
45
|
+
readonly name: "";
|
|
46
|
+
readonly type: "tuple";
|
|
47
|
+
readonly internalType: "struct ExecutionId.Info";
|
|
48
|
+
readonly components: readonly [{
|
|
49
|
+
readonly name: "deployer";
|
|
50
|
+
readonly type: "string";
|
|
51
|
+
readonly internalType: "string";
|
|
52
|
+
}, {
|
|
53
|
+
readonly name: "executionId";
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
readonly internalType: "string";
|
|
56
|
+
}, {
|
|
57
|
+
readonly name: "forkAlias";
|
|
58
|
+
readonly type: "string";
|
|
59
|
+
readonly internalType: "string";
|
|
60
|
+
}];
|
|
61
|
+
}];
|
|
62
|
+
readonly stateMutability: "view";
|
|
63
|
+
}];
|
|
64
|
+
export type VerifyTestnetParams = {
|
|
65
|
+
executionId: string;
|
|
66
|
+
} | {
|
|
67
|
+
alias: string;
|
|
68
|
+
} | {
|
|
69
|
+
executionId: string;
|
|
70
|
+
alias: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Tries to read the contract that is deployed on every Gearbox testnet
|
|
74
|
+
* and verify that we're on expected testnet.
|
|
75
|
+
*
|
|
76
|
+
* Used to check that wallet is using correct RPC for the testnet.
|
|
77
|
+
*
|
|
78
|
+
* @param client - Public client
|
|
79
|
+
* @param expected - Expected tesnet alias or execution id
|
|
80
|
+
* @returns True if we're on expected testnet
|
|
81
|
+
*/
|
|
82
|
+
export declare function verifyTestnet(client: PublicClient, expected: VerifyTestnetParams): Promise<boolean>;
|