@imtbl/sdk 0.0.1-alpha.1 → 0.0.1-alpha.2
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/browser/checkout.js +2 -0
- package/dist/checkout_sdk.d.ts +641 -0
- package/dist/checkout_sdk.js +468 -0
- package/dist/checkout_widgets.d.ts +14442 -0
- package/dist/checkout_widgets.js +180 -0
- package/dist/index.cjs +554 -0
- package/dist/index.d.ts +14841 -5
- package/dist/index.js +555 -2
- package/package.json +15 -5
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
import { utils, Contract } from 'ethers';
|
|
2
|
+
import $7v2Z6$metamaskdetectprovider from '@metamask/detect-provider';
|
|
3
|
+
import { Web3Provider } from '@ethersproject/providers';
|
|
4
|
+
|
|
5
|
+
const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
6
|
+
{
|
|
7
|
+
constant: true,
|
|
8
|
+
inputs: [],
|
|
9
|
+
name: "name",
|
|
10
|
+
outputs: [
|
|
11
|
+
{
|
|
12
|
+
name: "",
|
|
13
|
+
type: "string"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
payable: false,
|
|
17
|
+
type: "function"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
constant: true,
|
|
21
|
+
inputs: [],
|
|
22
|
+
name: "decimals",
|
|
23
|
+
outputs: [
|
|
24
|
+
{
|
|
25
|
+
name: "",
|
|
26
|
+
type: "uint8"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
payable: false,
|
|
30
|
+
type: "function"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
constant: true,
|
|
34
|
+
inputs: [
|
|
35
|
+
{
|
|
36
|
+
name: "_owner",
|
|
37
|
+
type: "address"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
name: "balanceOf",
|
|
41
|
+
outputs: [
|
|
42
|
+
{
|
|
43
|
+
name: "balance",
|
|
44
|
+
type: "uint256"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
payable: false,
|
|
48
|
+
type: "function"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
constant: true,
|
|
52
|
+
inputs: [],
|
|
53
|
+
name: "symbol",
|
|
54
|
+
outputs: [
|
|
55
|
+
{
|
|
56
|
+
name: "",
|
|
57
|
+
type: "string"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
payable: false,
|
|
61
|
+
type: "function"
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
let $d176a05e966364ba$export$3bfad4d03ada24c4;
|
|
67
|
+
(function(ConnectionProviders) {
|
|
68
|
+
ConnectionProviders["METAMASK"] = "metamask";
|
|
69
|
+
})($d176a05e966364ba$export$3bfad4d03ada24c4 || ($d176a05e966364ba$export$3bfad4d03ada24c4 = {}));
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
let $a47e48dd2c04791b$export$c06e1e7429de6283;
|
|
73
|
+
(function(ChainId) {
|
|
74
|
+
ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
|
|
75
|
+
ChainId[ChainId["GOERLI"] = 5] = "GOERLI";
|
|
76
|
+
ChainId[ChainId["POLYGON"] = 137] = "POLYGON";
|
|
77
|
+
})($a47e48dd2c04791b$export$c06e1e7429de6283 || ($a47e48dd2c04791b$export$c06e1e7429de6283 = {}));
|
|
78
|
+
const $a47e48dd2c04791b$export$f61f4aaec62f6be9 = {
|
|
79
|
+
[$a47e48dd2c04791b$export$c06e1e7429de6283.ETHEREUM]: {
|
|
80
|
+
chainIdHex: "0x1",
|
|
81
|
+
chainName: "Ethereum",
|
|
82
|
+
rpcUrls: [
|
|
83
|
+
"https://mainnet.infura.io/v3/"
|
|
84
|
+
],
|
|
85
|
+
nativeCurrency: {
|
|
86
|
+
name: "Ethereum",
|
|
87
|
+
symbol: "ETH",
|
|
88
|
+
decimals: 18
|
|
89
|
+
},
|
|
90
|
+
blockExplorerUrls: [
|
|
91
|
+
"https://etherscan.io/"
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
[$a47e48dd2c04791b$export$c06e1e7429de6283.GOERLI]: {
|
|
95
|
+
chainIdHex: "0x5",
|
|
96
|
+
chainName: "Goerli",
|
|
97
|
+
rpcUrls: [
|
|
98
|
+
"https://goerli.infura.io/v3/"
|
|
99
|
+
],
|
|
100
|
+
nativeCurrency: {
|
|
101
|
+
name: "Goerli Eth",
|
|
102
|
+
symbol: "ETH",
|
|
103
|
+
decimals: 18
|
|
104
|
+
},
|
|
105
|
+
blockExplorerUrls: [
|
|
106
|
+
"https://goerli.etherscan.io/"
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
[$a47e48dd2c04791b$export$c06e1e7429de6283.POLYGON]: {
|
|
110
|
+
chainIdHex: "0x89",
|
|
111
|
+
chainName: "Polygon",
|
|
112
|
+
rpcUrls: [
|
|
113
|
+
"https://polygon-rpc.com"
|
|
114
|
+
],
|
|
115
|
+
nativeCurrency: {
|
|
116
|
+
name: "MATIC",
|
|
117
|
+
symbol: "MATIC",
|
|
118
|
+
decimals: 18
|
|
119
|
+
},
|
|
120
|
+
blockExplorerUrls: [
|
|
121
|
+
"https://polygonscan.com/"
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
const $4f91c5f280efe242$export$a130407f3423b97d = {
|
|
132
|
+
CHECK_CONNECTION: "eth_accounts",
|
|
133
|
+
CONNECT: "eth_requestAccounts",
|
|
134
|
+
ADD_NETWORK: "wallet_addEthereumChain",
|
|
135
|
+
SWITCH_NETWORK: "wallet_switchEthereumChain"
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
let $a8bc256d81a5e2c1$export$e3dc0620abde7f5a;
|
|
142
|
+
(function(CheckoutErrorType) {
|
|
143
|
+
CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
|
|
144
|
+
CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
|
|
145
|
+
CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
|
|
146
|
+
CheckoutErrorType["METAMASK_PROVIDER_ERROR"] = "METAMASK_PROVIDER_ERROR";
|
|
147
|
+
CheckoutErrorType["CHAIN_NOT_SUPPORTED_ERROR"] = "CHAIN_NOT_SUPPORTED_ERROR";
|
|
148
|
+
CheckoutErrorType["PROVIDER_REQUEST_MISSING_ERROR"] = "PROVIDER_REQUEST_MISSING_ERROR";
|
|
149
|
+
CheckoutErrorType["USER_REJECTED_REQUEST_ERROR"] = "USER_REJECTED_REQUEST_ERROR";
|
|
150
|
+
CheckoutErrorType["TRANSACTION_ERROR"] = "TRANSACTION_ERROR";
|
|
151
|
+
})($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
|
|
152
|
+
class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
|
|
153
|
+
constructor(message, type){
|
|
154
|
+
super(message);
|
|
155
|
+
this.type = type;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const $a8bc256d81a5e2c1$export$bacc563de539c6c3 = async (fn, customError)=>{
|
|
159
|
+
try {
|
|
160
|
+
return await fn();
|
|
161
|
+
} catch (error) {
|
|
162
|
+
const errorMessage = customError.message || `${error.message}` || "UnknownError";
|
|
163
|
+
throw new $a8bc256d81a5e2c1$export$b722478a3cbfa3bc(errorMessage, customError.type);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
async function $de192de6ef100f9f$export$79f13b4cfaaf0d09(provider) {
|
|
174
|
+
const network = await provider.getNetwork();
|
|
175
|
+
if (!Object.values(($a47e48dd2c04791b$export$c06e1e7429de6283)).includes(network.chainId)) // return empty details
|
|
176
|
+
return {};
|
|
177
|
+
const chainIdNetworkInfo = ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[network.chainId];
|
|
178
|
+
const networkInfo = {
|
|
179
|
+
name: chainIdNetworkInfo.chainName,
|
|
180
|
+
chainId: parseInt(chainIdNetworkInfo.chainIdHex, 16),
|
|
181
|
+
nativeCurrency: chainIdNetworkInfo.nativeCurrency
|
|
182
|
+
};
|
|
183
|
+
return networkInfo;
|
|
184
|
+
}
|
|
185
|
+
async function $de192de6ef100f9f$export$b827d9418aeb5dbd(provider, chainId) {
|
|
186
|
+
if (!Object.values(($a47e48dd2c04791b$export$c06e1e7429de6283)).includes(chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`${chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR);
|
|
187
|
+
if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("provider object is missing request function", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
|
|
188
|
+
// WT-1146 - Refer to the README in this folder for explantion on the switch network flow
|
|
189
|
+
try {
|
|
190
|
+
await $de192de6ef100f9f$var$switchNetworkInWallet(provider, chainId);
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
192
|
+
} catch (err) {
|
|
193
|
+
if (err.message.includes("Unrecognized chain ID")) try {
|
|
194
|
+
await $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId);
|
|
195
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
196
|
+
} catch (err) {
|
|
197
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("user cancelled the add network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
|
|
198
|
+
}
|
|
199
|
+
else throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("user cancelled the switch network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
|
|
200
|
+
}
|
|
201
|
+
// we can assume that if the above succeeds then user has successfully
|
|
202
|
+
// switched to the network specified
|
|
203
|
+
const newNetwork = ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId];
|
|
204
|
+
return {
|
|
205
|
+
network: {
|
|
206
|
+
name: newNetwork.chainName,
|
|
207
|
+
chainId: parseInt(newNetwork.chainIdHex, 16),
|
|
208
|
+
nativeCurrency: newNetwork.nativeCurrency
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
// these functions should not be exported. These functions should be used as part of an exported function e.g switchWalletNetwork() above.
|
|
213
|
+
// make sure to check if(provider.provider?.request) in the exported function and throw an error
|
|
214
|
+
async function $de192de6ef100f9f$var$switchNetworkInWallet(provider, chainId) {
|
|
215
|
+
if (provider.provider?.request) return await provider.provider.request({
|
|
216
|
+
method: ($4f91c5f280efe242$export$a130407f3423b97d).SWITCH_NETWORK,
|
|
217
|
+
params: [
|
|
218
|
+
{
|
|
219
|
+
chainId: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainIdHex
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
async function $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId) {
|
|
225
|
+
if (provider.provider?.request) {
|
|
226
|
+
const addNetwork = {
|
|
227
|
+
chainId: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainIdHex,
|
|
228
|
+
chainName: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainName,
|
|
229
|
+
rpcUrls: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].rpcUrls,
|
|
230
|
+
nativeCurrency: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].nativeCurrency,
|
|
231
|
+
blockExplorerUrls: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].blockExplorerUrls
|
|
232
|
+
};
|
|
233
|
+
return await provider.provider.request({
|
|
234
|
+
method: ($4f91c5f280efe242$export$a130407f3423b97d).ADD_NETWORK,
|
|
235
|
+
params: [
|
|
236
|
+
addNetwork
|
|
237
|
+
]
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
let $efe60cea83bfc4e8$export$f04a61298a47a40f;
|
|
247
|
+
(function(Icon) {
|
|
248
|
+
Icon["ETH"] = "data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg xmlns='http://www.w3.org/2000/svg' xml:space='preserve' width='100%25' height='100%25' version='1.1' shape-rendering='geometricPrecision' text-rendering='geometricPrecision' image-rendering='optimizeQuality' fill-rule='evenodd' clip-rule='evenodd'%0AviewBox='0 0 784.37 1277.39' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:xodm='http://www.corel.com/coreldraw/odm/2003'%3E%3Cg id='Layer_x0020_1'%3E%3Cmetadata id='CorelCorpID_0Corel-Layer'/%3E%3Cg id='_1421394342400'%3E%3Cg%3E%3Cpolygon fill='%23343434' fill-rule='nonzero' points='392.07,0 383.5,29.11 383.5,873.74 392.07,882.29 784.13,650.54 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,0 -0,650.54 392.07,882.29 392.07,472.33 '/%3E%3Cpolygon fill='%233C3C3B' fill-rule='nonzero' points='392.07,956.52 387.24,962.41 387.24,1263.28 392.07,1277.38 784.37,724.89 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,1277.38 392.07,956.52 -0,724.89 '/%3E%3Cpolygon fill='%23141414' fill-rule='nonzero' points='392.07,882.29 784.13,650.54 392.07,472.33 '/%3E%3Cpolygon fill='%23393939' fill-rule='nonzero' points='0,650.54 392.07,882.29 392.07,472.33 '/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A";
|
|
249
|
+
Icon["MATIC"] = "data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 38.4 33.5' style='enable-background:new 0 0 38.4 33.5;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%238247E5;%7D%0A%3C/style%3E%3Cg%3E%3Cpath class='st0' d='M29,10.2c-0.7-0.4-1.6-0.4-2.4,0L21,13.5l-3.8,2.1l-5.5,3.3c-0.7,0.4-1.6,0.4-2.4,0L5,16.3 c-0.7-0.4-1.2-1.2-1.2-2.1v-5c0-0.8,0.4-1.6,1.2-2.1l4.3-2.5c0.7-0.4,1.6-0.4,2.4,0L16,7.2c0.7,0.4,1.2,1.2,1.2,2.1v3.3l3.8-2.2V7 c0-0.8-0.4-1.6-1.2-2.1l-8-4.7c-0.7-0.4-1.6-0.4-2.4,0L1.2,5C0.4,5.4,0,6.2,0,7v9.4c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l5.5-3.2l3.8-2.2l5.5-3.2c0.7-0.4,1.6-0.4,2.4,0l4.3,2.5c0.7,0.4,1.2,1.2,1.2,2.1v5c0,0.8-0.4,1.6-1.2,2.1 L29,28.8c-0.7,0.4-1.6,0.4-2.4,0l-4.3-2.5c-0.7-0.4-1.2-1.2-1.2-2.1V21l-3.8,2.2v3.3c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l8.1-4.7c0.7-0.4,1.2-1.2,1.2-2.1V17c0-0.8-0.4-1.6-1.2-2.1L29,10.2z'/%3E%3C/g%3E%3C/svg%3E%0A";
|
|
250
|
+
Icon["IMX"] = "data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 139 113' style='enable-background:new 0 0 139 113;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bclip-path:url(%23SVGID_00000053504646934646330740000009134454895836103350_);%7D .st1%7Bfill:%2317B5CB;%7D%0A%3C/style%3E%3Cg%3E%3Cdefs%3E%3Crect id='SVGID_1_' width='139' height='113'/%3E%3C/defs%3E%3CclipPath id='SVGID_00000035518931339590433170000002358037249938198420_'%3E%3Cuse xlink:href='%23SVGID_1_' style='overflow:visible;'/%3E%3C/clipPath%3E%3Cg style='clip-path:url(%23SVGID_00000035518931339590433170000002358037249938198420_);'%3E%3Cpath class='st1' d='M124.1,0h14.6L79.5,67.6c-1.5,1.7-1.6,4.3-0.1,6.1l34.1,39.7H98.3L66.8,76.6l-1.6-2c-1.5-1.7-1.4-4.4,0.1-6.1 L124.1,0z'/%3E%3Cpath class='st1' d='M91.2,73.7c-1-1.1-1.3-2.7-1-4.1c0.3-0.8,0.8-1.6,1.4-2.2l3.9-4.3l43.5,50.3h-13.8 C125.2,113.4,99.7,83.6,91.2,73.7z'/%3E%3Cpath class='st1' d='M15.2,113.4H0l46.6-53.9c1.5-1.7,1.5-4.3,0-6L0.4,0H15l46.5,53.9c1.2,1.6,1.4,3.9,0.1,5.4 C49.4,73.4,15.2,113.4,15.2,113.4z'/%3E%3Cpath class='st1' d='M40.6,0h-14l43.1,49.9c0,0,0.1-0.1,4.9-5.8c1.3-1.5,1.6-3.4,0.1-4.9C65.7,30,40.6,0,40.6,0z'/%3E%3Cpath class='st1' d='M82.6,34.8L112.5,0H98.3L82.7,18.2l-4.5,5.3c-1.5,1.7-1.6,4.3-0.1,6.1C79.2,30.9,82.6,34.8,82.6,34.8z'/%3E%3Cpath class='st1' d='M56.6,78.6l-29.9,34.8h14.1l15.6-18.2l4.5-5.3c1.5-1.7,1.6-4.3,0.1-6.1C59.9,82.5,56.6,78.6,56.6,78.6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A";
|
|
251
|
+
})($efe60cea83bfc4e8$export$f04a61298a47a40f || ($efe60cea83bfc4e8$export$f04a61298a47a40f = {}));
|
|
252
|
+
const $efe60cea83bfc4e8$export$3dbcce43073f40c7 = [
|
|
253
|
+
{
|
|
254
|
+
name: "Ethereum",
|
|
255
|
+
symbol: "ETH",
|
|
256
|
+
decimals: 18,
|
|
257
|
+
icon: "data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg xmlns='http://www.w3.org/2000/svg' xml:space='preserve' width='100%25' height='100%25' version='1.1' shape-rendering='geometricPrecision' text-rendering='geometricPrecision' image-rendering='optimizeQuality' fill-rule='evenodd' clip-rule='evenodd'%0AviewBox='0 0 784.37 1277.39' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:xodm='http://www.corel.com/coreldraw/odm/2003'%3E%3Cg id='Layer_x0020_1'%3E%3Cmetadata id='CorelCorpID_0Corel-Layer'/%3E%3Cg id='_1421394342400'%3E%3Cg%3E%3Cpolygon fill='%23343434' fill-rule='nonzero' points='392.07,0 383.5,29.11 383.5,873.74 392.07,882.29 784.13,650.54 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,0 -0,650.54 392.07,882.29 392.07,472.33 '/%3E%3Cpolygon fill='%233C3C3B' fill-rule='nonzero' points='392.07,956.52 387.24,962.41 387.24,1263.28 392.07,1277.38 784.37,724.89 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,1277.38 392.07,956.52 -0,724.89 '/%3E%3Cpolygon fill='%23141414' fill-rule='nonzero' points='392.07,882.29 784.13,650.54 392.07,472.33 '/%3E%3Cpolygon fill='%23393939' fill-rule='nonzero' points='0,650.54 392.07,882.29 392.07,472.33 '/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: "Matic",
|
|
261
|
+
symbol: "MATIC",
|
|
262
|
+
address: "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0",
|
|
263
|
+
decimals: 18,
|
|
264
|
+
icon: "data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 38.4 33.5' style='enable-background:new 0 0 38.4 33.5;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%238247E5;%7D%0A%3C/style%3E%3Cg%3E%3Cpath class='st0' d='M29,10.2c-0.7-0.4-1.6-0.4-2.4,0L21,13.5l-3.8,2.1l-5.5,3.3c-0.7,0.4-1.6,0.4-2.4,0L5,16.3 c-0.7-0.4-1.2-1.2-1.2-2.1v-5c0-0.8,0.4-1.6,1.2-2.1l4.3-2.5c0.7-0.4,1.6-0.4,2.4,0L16,7.2c0.7,0.4,1.2,1.2,1.2,2.1v3.3l3.8-2.2V7 c0-0.8-0.4-1.6-1.2-2.1l-8-4.7c-0.7-0.4-1.6-0.4-2.4,0L1.2,5C0.4,5.4,0,6.2,0,7v9.4c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l5.5-3.2l3.8-2.2l5.5-3.2c0.7-0.4,1.6-0.4,2.4,0l4.3,2.5c0.7,0.4,1.2,1.2,1.2,2.1v5c0,0.8-0.4,1.6-1.2,2.1 L29,28.8c-0.7,0.4-1.6,0.4-2.4,0l-4.3-2.5c-0.7-0.4-1.2-1.2-1.2-2.1V21l-3.8,2.2v3.3c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l8.1-4.7c0.7-0.4,1.2-1.2,1.2-2.1V17c0-0.8-0.4-1.6-1.2-2.1L29,10.2z'/%3E%3C/g%3E%3C/svg%3E%0A"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: "Immutable X",
|
|
268
|
+
symbol: "IMX",
|
|
269
|
+
address: "0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF",
|
|
270
|
+
decimals: 18,
|
|
271
|
+
icon: "data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 139 113' style='enable-background:new 0 0 139 113;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bclip-path:url(%23SVGID_00000053504646934646330740000009134454895836103350_);%7D .st1%7Bfill:%2317B5CB;%7D%0A%3C/style%3E%3Cg%3E%3Cdefs%3E%3Crect id='SVGID_1_' width='139' height='113'/%3E%3C/defs%3E%3CclipPath id='SVGID_00000035518931339590433170000002358037249938198420_'%3E%3Cuse xlink:href='%23SVGID_1_' style='overflow:visible;'/%3E%3C/clipPath%3E%3Cg style='clip-path:url(%23SVGID_00000035518931339590433170000002358037249938198420_);'%3E%3Cpath class='st1' d='M124.1,0h14.6L79.5,67.6c-1.5,1.7-1.6,4.3-0.1,6.1l34.1,39.7H98.3L66.8,76.6l-1.6-2c-1.5-1.7-1.4-4.4,0.1-6.1 L124.1,0z'/%3E%3Cpath class='st1' d='M91.2,73.7c-1-1.1-1.3-2.7-1-4.1c0.3-0.8,0.8-1.6,1.4-2.2l3.9-4.3l43.5,50.3h-13.8 C125.2,113.4,99.7,83.6,91.2,73.7z'/%3E%3Cpath class='st1' d='M15.2,113.4H0l46.6-53.9c1.5-1.7,1.5-4.3,0-6L0.4,0H15l46.5,53.9c1.2,1.6,1.4,3.9,0.1,5.4 C49.4,73.4,15.2,113.4,15.2,113.4z'/%3E%3Cpath class='st1' d='M40.6,0h-14l43.1,49.9c0,0,0.1-0.1,4.9-5.8c1.3-1.5,1.6-3.4,0.1-4.9C65.7,30,40.6,0,40.6,0z'/%3E%3Cpath class='st1' d='M82.6,34.8L112.5,0H98.3L82.7,18.2l-4.5,5.3c-1.5,1.7-1.6,4.3-0.1,6.1C79.2,30.9,82.6,34.8,82.6,34.8z'/%3E%3Cpath class='st1' d='M56.6,78.6l-29.9,34.8h14.1l15.6-18.2l4.5-5.3c1.5-1.7,1.6-4.3,0.1-6.1C59.9,82.5,56.6,78.6,56.6,78.6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A"
|
|
272
|
+
}
|
|
273
|
+
];
|
|
274
|
+
const $efe60cea83bfc4e8$var$goerliTokensList = [
|
|
275
|
+
{
|
|
276
|
+
name: "Ethereum",
|
|
277
|
+
symbol: "ETH",
|
|
278
|
+
decimals: 18,
|
|
279
|
+
icon: "data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg xmlns='http://www.w3.org/2000/svg' xml:space='preserve' width='100%25' height='100%25' version='1.1' shape-rendering='geometricPrecision' text-rendering='geometricPrecision' image-rendering='optimizeQuality' fill-rule='evenodd' clip-rule='evenodd'%0AviewBox='0 0 784.37 1277.39' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:xodm='http://www.corel.com/coreldraw/odm/2003'%3E%3Cg id='Layer_x0020_1'%3E%3Cmetadata id='CorelCorpID_0Corel-Layer'/%3E%3Cg id='_1421394342400'%3E%3Cg%3E%3Cpolygon fill='%23343434' fill-rule='nonzero' points='392.07,0 383.5,29.11 383.5,873.74 392.07,882.29 784.13,650.54 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,0 -0,650.54 392.07,882.29 392.07,472.33 '/%3E%3Cpolygon fill='%233C3C3B' fill-rule='nonzero' points='392.07,956.52 387.24,962.41 387.24,1263.28 392.07,1277.38 784.37,724.89 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,1277.38 392.07,956.52 -0,724.89 '/%3E%3Cpolygon fill='%23141414' fill-rule='nonzero' points='392.07,882.29 784.13,650.54 392.07,472.33 '/%3E%3Cpolygon fill='%23393939' fill-rule='nonzero' points='0,650.54 392.07,882.29 392.07,472.33 '/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: "Immutable X",
|
|
283
|
+
symbol: "IMX",
|
|
284
|
+
address: "0x1facdd0165489f373255a90304650e15481b2c85",
|
|
285
|
+
decimals: 18,
|
|
286
|
+
icon: "data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 139 113' style='enable-background:new 0 0 139 113;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bclip-path:url(%23SVGID_00000053504646934646330740000009134454895836103350_);%7D .st1%7Bfill:%2317B5CB;%7D%0A%3C/style%3E%3Cg%3E%3Cdefs%3E%3Crect id='SVGID_1_' width='139' height='113'/%3E%3C/defs%3E%3CclipPath id='SVGID_00000035518931339590433170000002358037249938198420_'%3E%3Cuse xlink:href='%23SVGID_1_' style='overflow:visible;'/%3E%3C/clipPath%3E%3Cg style='clip-path:url(%23SVGID_00000035518931339590433170000002358037249938198420_);'%3E%3Cpath class='st1' d='M124.1,0h14.6L79.5,67.6c-1.5,1.7-1.6,4.3-0.1,6.1l34.1,39.7H98.3L66.8,76.6l-1.6-2c-1.5-1.7-1.4-4.4,0.1-6.1 L124.1,0z'/%3E%3Cpath class='st1' d='M91.2,73.7c-1-1.1-1.3-2.7-1-4.1c0.3-0.8,0.8-1.6,1.4-2.2l3.9-4.3l43.5,50.3h-13.8 C125.2,113.4,99.7,83.6,91.2,73.7z'/%3E%3Cpath class='st1' d='M15.2,113.4H0l46.6-53.9c1.5-1.7,1.5-4.3,0-6L0.4,0H15l46.5,53.9c1.2,1.6,1.4,3.9,0.1,5.4 C49.4,73.4,15.2,113.4,15.2,113.4z'/%3E%3Cpath class='st1' d='M40.6,0h-14l43.1,49.9c0,0,0.1-0.1,4.9-5.8c1.3-1.5,1.6-3.4,0.1-4.9C65.7,30,40.6,0,40.6,0z'/%3E%3Cpath class='st1' d='M82.6,34.8L112.5,0H98.3L82.7,18.2l-4.5,5.3c-1.5,1.7-1.6,4.3-0.1,6.1C79.2,30.9,82.6,34.8,82.6,34.8z'/%3E%3Cpath class='st1' d='M56.6,78.6l-29.9,34.8h14.1l15.6-18.2l4.5-5.3c1.5-1.7,1.6-4.3,0.1-6.1C59.9,82.5,56.6,78.6,56.6,78.6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A"
|
|
287
|
+
}
|
|
288
|
+
];
|
|
289
|
+
const $efe60cea83bfc4e8$var$polygonTokensList = [];
|
|
290
|
+
const $efe60cea83bfc4e8$export$473cec51305fdae8 = (chainId)=>{
|
|
291
|
+
let tokenList = [];
|
|
292
|
+
switch(chainId){
|
|
293
|
+
case ($a47e48dd2c04791b$export$c06e1e7429de6283).ETHEREUM:
|
|
294
|
+
tokenList = $efe60cea83bfc4e8$export$3dbcce43073f40c7;
|
|
295
|
+
break;
|
|
296
|
+
case ($a47e48dd2c04791b$export$c06e1e7429de6283).GOERLI:
|
|
297
|
+
tokenList = $efe60cea83bfc4e8$var$goerliTokensList;
|
|
298
|
+
break;
|
|
299
|
+
case ($a47e48dd2c04791b$export$c06e1e7429de6283).POLYGON:
|
|
300
|
+
tokenList = $efe60cea83bfc4e8$var$polygonTokensList;
|
|
301
|
+
break;
|
|
302
|
+
default:
|
|
303
|
+
tokenList = $efe60cea83bfc4e8$export$3dbcce43073f40c7;
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
tokens: tokenList
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (provider, walletAddress)=>{
|
|
314
|
+
return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
315
|
+
const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(provider);
|
|
316
|
+
const balance = await provider.getBalance(walletAddress);
|
|
317
|
+
return {
|
|
318
|
+
balance: balance,
|
|
319
|
+
formattedBalance: (utils).formatUnits(balance, networkInfo.nativeCurrency.decimals),
|
|
320
|
+
token: networkInfo.nativeCurrency
|
|
321
|
+
};
|
|
322
|
+
}, {
|
|
323
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, contractAddress) {
|
|
327
|
+
return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
328
|
+
const contract = new (Contract)(contractAddress, JSON.stringify(($762782b6c862d954$export$db5daa1b5156ccfe)), provider);
|
|
329
|
+
const name = await contract.name();
|
|
330
|
+
const symbol = await contract.symbol();
|
|
331
|
+
const balance = await contract.balanceOf(walletAddress);
|
|
332
|
+
const decimals = await contract.decimals();
|
|
333
|
+
const formattedBalance = (utils).formatUnits(balance, decimals);
|
|
334
|
+
return {
|
|
335
|
+
balance: balance,
|
|
336
|
+
formattedBalance: formattedBalance,
|
|
337
|
+
token: {
|
|
338
|
+
name: name,
|
|
339
|
+
symbol: symbol,
|
|
340
|
+
decimals: decimals,
|
|
341
|
+
address: contractAddress
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
}, {
|
|
345
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
const $1564e43dde50bb61$export$fee49741664a4d7e = async (provider, walletAddress, chainId)=>{
|
|
349
|
+
if (!Object.values(($a47e48dd2c04791b$export$c06e1e7429de6283)).includes(chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`ChainId ${chainId} is not supported`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR);
|
|
350
|
+
if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("provider object is missing request function", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
|
|
351
|
+
const tokenList = ($efe60cea83bfc4e8$export$473cec51305fdae8)(chainId);
|
|
352
|
+
const allBalancePromises = [];
|
|
353
|
+
allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(provider, walletAddress));
|
|
354
|
+
tokenList.tokens.filter((token)=>token.address).forEach((token)=>allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, token.address ?? "")));
|
|
355
|
+
const balanceResults = await Promise.allSettled(allBalancePromises);
|
|
356
|
+
const getBalanceResults = balanceResults.filter((result)=>result.status === "fulfilled").map((fulfilledResult)=>fulfilledResult.value);
|
|
357
|
+
return {
|
|
358
|
+
balances: getBalanceResults
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
async function $c99672cf2294e839$export$2d040992269b4717(providerPreference) {
|
|
371
|
+
const provider = await $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference);
|
|
372
|
+
if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
|
|
373
|
+
const accounts = await provider.provider.request({
|
|
374
|
+
method: ($4f91c5f280efe242$export$a130407f3423b97d).CHECK_CONNECTION,
|
|
375
|
+
params: []
|
|
376
|
+
});
|
|
377
|
+
// accounts[0] will have the active account if connected.
|
|
378
|
+
return {
|
|
379
|
+
isConnected: accounts && accounts.length > 0,
|
|
380
|
+
walletAddress: accounts[0] ?? ""
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
async function $c99672cf2294e839$export$fba2f6c3656e07c1(params) {
|
|
384
|
+
const web3Provider = await $c99672cf2294e839$var$getWalletProviderForPreference(params.providerPreference);
|
|
385
|
+
await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
386
|
+
if (!web3Provider || !web3Provider?.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
|
|
387
|
+
// this makes the request to the wallet to connect i.e request eth accounts ('eth_requestAccounts')
|
|
388
|
+
await web3Provider.provider.request({
|
|
389
|
+
method: ($4f91c5f280efe242$export$a130407f3423b97d).CONNECT,
|
|
390
|
+
params: []
|
|
391
|
+
});
|
|
392
|
+
}, {
|
|
393
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR
|
|
394
|
+
});
|
|
395
|
+
return web3Provider;
|
|
396
|
+
}
|
|
397
|
+
async function $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference) {
|
|
398
|
+
let web3Provider = null;
|
|
399
|
+
switch(providerPreference){
|
|
400
|
+
case ($d176a05e966364ba$export$3bfad4d03ada24c4).METAMASK:
|
|
401
|
+
web3Provider = await $c99672cf2294e839$var$getMetaMaskProvider();
|
|
402
|
+
break;
|
|
403
|
+
default:
|
|
404
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider preference was not detected", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CONNECT_PROVIDER_ERROR);
|
|
405
|
+
}
|
|
406
|
+
return web3Provider;
|
|
407
|
+
}
|
|
408
|
+
async function $c99672cf2294e839$var$getMetaMaskProvider() {
|
|
409
|
+
const provider = await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
410
|
+
return await ($7v2Z6$metamaskdetectprovider)();
|
|
411
|
+
}, {
|
|
412
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR
|
|
413
|
+
});
|
|
414
|
+
if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
|
|
415
|
+
return new (Web3Provider)(provider);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
const $dbe95599a4661140$export$8e0e7ffc78696d30 = async (params)=>{
|
|
424
|
+
const { provider: provider , transaction: transaction } = params;
|
|
425
|
+
return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
426
|
+
const transactionResponse = await provider.getSigner().sendTransaction(transaction);
|
|
427
|
+
return {
|
|
428
|
+
transactionResponse: transactionResponse
|
|
429
|
+
};
|
|
430
|
+
}, {
|
|
431
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).TRANSACTION_ERROR
|
|
432
|
+
});
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
439
|
+
async checkIsWalletConnected(params) {
|
|
440
|
+
return $c99672cf2294e839$export$2d040992269b4717(params.providerPreference);
|
|
441
|
+
}
|
|
442
|
+
async connect(params) {
|
|
443
|
+
const provider = await $c99672cf2294e839$export$fba2f6c3656e07c1(params);
|
|
444
|
+
const network = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(provider);
|
|
445
|
+
return {
|
|
446
|
+
provider: provider,
|
|
447
|
+
network: network
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
async switchNetwork(params) {
|
|
451
|
+
return await ($de192de6ef100f9f$export$b827d9418aeb5dbd)(params.provider, params.chainId);
|
|
452
|
+
}
|
|
453
|
+
async getBalance(params) {
|
|
454
|
+
if (!params.contractAddress || params.contractAddress === "") return await $1564e43dde50bb61$export$df96cd8d56be0ab1(params.provider, params.walletAddress);
|
|
455
|
+
return await $1564e43dde50bb61$export$60e0fe116a0e6ed0(params.provider, params.walletAddress, params.contractAddress);
|
|
456
|
+
}
|
|
457
|
+
async getAllBalances(params) {
|
|
458
|
+
return $1564e43dde50bb61$export$fee49741664a4d7e(params.provider, params.walletAddress, params.chainId);
|
|
459
|
+
}
|
|
460
|
+
getTokenAllowList(params) {
|
|
461
|
+
return $efe60cea83bfc4e8$export$473cec51305fdae8(params.chainId);
|
|
462
|
+
}
|
|
463
|
+
async sendTransaction(params) {
|
|
464
|
+
return await $dbe95599a4661140$export$8e0e7ffc78696d30(params);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export { $a47e48dd2c04791b$export$c06e1e7429de6283 as ChainId, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $d176a05e966364ba$export$3bfad4d03ada24c4 as ConnectionProviders };
|