@megaeth-labs/wallet-sdk 0.1.15 → 0.1.16-beta.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/README.md +17 -0
- package/dist/index.cjs +8 -20
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -20
- package/package.json +66 -68
package/README.md
CHANGED
|
@@ -182,6 +182,23 @@ if (result.status === 'approved') {
|
|
|
182
182
|
}
|
|
183
183
|
```
|
|
184
184
|
|
|
185
|
+
### Call Contract Method (Large Payload)
|
|
186
|
+
If you are calling a contract method with a large payload (e.g. deploying a contract via a factory), you can override the default max gas spending limit.
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
const result = await mega.callContract({
|
|
190
|
+
address: '0xContractAddress',
|
|
191
|
+
abi: contractABI,
|
|
192
|
+
functionName: 'deplosy',
|
|
193
|
+
args: [],
|
|
194
|
+
maxGasAllowance: parseEther('0.0005')
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
if (result.status === 'approved') {
|
|
198
|
+
console.log('Transaction hash:', result.receipt.hash);
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
185
202
|
### Silent Contract Call (Session Keys)
|
|
186
203
|
Execute a contract method silently using session key permissions (no user approval required).
|
|
187
204
|
|
package/dist/index.cjs
CHANGED
|
@@ -56,28 +56,16 @@ var WALLET_URL = "https://account.megaeth.com";
|
|
|
56
56
|
var LOCAL_WALLET_URL = "http://localhost:4000";
|
|
57
57
|
|
|
58
58
|
// src/helpers.ts
|
|
59
|
-
var param = (key, value) => value !== void 0 && value !== "" ? `${key}=${encodeURIComponent(String(value))}` : void 0;
|
|
60
59
|
var getWalletUrl = (config) => {
|
|
61
|
-
const origin =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
param("network", config.network),
|
|
70
|
-
param("sponsorUrl", config.sponsorUrl),
|
|
71
|
-
param("sponsorMode", config.sponsorMode),
|
|
72
|
-
param("sponsorToken", config.sponsorToken),
|
|
73
|
-
param("debug", config.debug),
|
|
74
|
-
param("logging", config.logging)
|
|
60
|
+
const origin = config.devMode ? LOCAL_WALLET_URL : WALLET_URL;
|
|
61
|
+
const params = [
|
|
62
|
+
`network=${config.network}`,
|
|
63
|
+
...config.sponsorUrl ? [`sponsorUrl=${config.sponsorUrl}`] : [],
|
|
64
|
+
...config.sponsorMode ? [`sponsorMode=${config.sponsorMode}`] : [],
|
|
65
|
+
...config.sponsorToken ? [`sponsorToken=${config.sponsorToken}`] : [],
|
|
66
|
+
...config.debug ? [`debug=${config.debug}`] : [],
|
|
67
|
+
...config.logging ? [`logging=${config.logging}`] : []
|
|
75
68
|
];
|
|
76
|
-
if (config.devMode) {
|
|
77
|
-
rawParams.push(param("apiUrl", config.apiUrl));
|
|
78
|
-
rawParams.push(param("relayerUrl", config.relayerUrl));
|
|
79
|
-
}
|
|
80
|
-
const params = rawParams.filter((value) => Boolean(value));
|
|
81
69
|
return {
|
|
82
70
|
origin,
|
|
83
71
|
uiUrl: `${origin}?${params.join("&")}`
|
package/dist/index.d.cts
CHANGED
|
@@ -7,9 +7,6 @@ interface Config {
|
|
|
7
7
|
logging?: LogLevel;
|
|
8
8
|
devMode?: boolean;
|
|
9
9
|
debug?: boolean;
|
|
10
|
-
walletOriginUrl?: string;
|
|
11
|
-
apiUrl?: string;
|
|
12
|
-
relayerUrl?: string;
|
|
13
10
|
sponsorUrl?: string;
|
|
14
11
|
sponsorMode?: SponsorMode;
|
|
15
12
|
sponsorToken?: SponsorToken;
|
|
@@ -34,8 +31,10 @@ interface CallContractRequest {
|
|
|
34
31
|
args?: any[];
|
|
35
32
|
data?: `0x${string}`;
|
|
36
33
|
silent?: boolean;
|
|
34
|
+
silentUIApproveFallback?: boolean;
|
|
37
35
|
value?: bigint | string;
|
|
38
36
|
sponsor?: boolean;
|
|
37
|
+
maxGasAllowance?: bigint;
|
|
39
38
|
}
|
|
40
39
|
interface GetFromContractRequest {
|
|
41
40
|
address: `0x${string}`;
|
|
@@ -63,6 +62,7 @@ interface TransactionResult {
|
|
|
63
62
|
receipt?: TransactionReceipt;
|
|
64
63
|
receipts?: TransactionReceipt[];
|
|
65
64
|
error?: string;
|
|
65
|
+
silentHasUsedFallback?: boolean;
|
|
66
66
|
}
|
|
67
67
|
interface SignMessageResponse {
|
|
68
68
|
status: 'success' | 'cancelled' | 'error';
|
package/dist/index.d.ts
CHANGED
|
@@ -7,9 +7,6 @@ interface Config {
|
|
|
7
7
|
logging?: LogLevel;
|
|
8
8
|
devMode?: boolean;
|
|
9
9
|
debug?: boolean;
|
|
10
|
-
walletOriginUrl?: string;
|
|
11
|
-
apiUrl?: string;
|
|
12
|
-
relayerUrl?: string;
|
|
13
10
|
sponsorUrl?: string;
|
|
14
11
|
sponsorMode?: SponsorMode;
|
|
15
12
|
sponsorToken?: SponsorToken;
|
|
@@ -34,8 +31,10 @@ interface CallContractRequest {
|
|
|
34
31
|
args?: any[];
|
|
35
32
|
data?: `0x${string}`;
|
|
36
33
|
silent?: boolean;
|
|
34
|
+
silentUIApproveFallback?: boolean;
|
|
37
35
|
value?: bigint | string;
|
|
38
36
|
sponsor?: boolean;
|
|
37
|
+
maxGasAllowance?: bigint;
|
|
39
38
|
}
|
|
40
39
|
interface GetFromContractRequest {
|
|
41
40
|
address: `0x${string}`;
|
|
@@ -63,6 +62,7 @@ interface TransactionResult {
|
|
|
63
62
|
receipt?: TransactionReceipt;
|
|
64
63
|
receipts?: TransactionReceipt[];
|
|
65
64
|
error?: string;
|
|
65
|
+
silentHasUsedFallback?: boolean;
|
|
66
66
|
}
|
|
67
67
|
interface SignMessageResponse {
|
|
68
68
|
status: 'success' | 'cancelled' | 'error';
|
package/dist/index.js
CHANGED
|
@@ -20,28 +20,16 @@ var WALLET_URL = "https://account.megaeth.com";
|
|
|
20
20
|
var LOCAL_WALLET_URL = "http://localhost:4000";
|
|
21
21
|
|
|
22
22
|
// src/helpers.ts
|
|
23
|
-
var param = (key, value) => value !== void 0 && value !== "" ? `${key}=${encodeURIComponent(String(value))}` : void 0;
|
|
24
23
|
var getWalletUrl = (config) => {
|
|
25
|
-
const origin =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
param("network", config.network),
|
|
34
|
-
param("sponsorUrl", config.sponsorUrl),
|
|
35
|
-
param("sponsorMode", config.sponsorMode),
|
|
36
|
-
param("sponsorToken", config.sponsorToken),
|
|
37
|
-
param("debug", config.debug),
|
|
38
|
-
param("logging", config.logging)
|
|
24
|
+
const origin = config.devMode ? LOCAL_WALLET_URL : WALLET_URL;
|
|
25
|
+
const params = [
|
|
26
|
+
`network=${config.network}`,
|
|
27
|
+
...config.sponsorUrl ? [`sponsorUrl=${config.sponsorUrl}`] : [],
|
|
28
|
+
...config.sponsorMode ? [`sponsorMode=${config.sponsorMode}`] : [],
|
|
29
|
+
...config.sponsorToken ? [`sponsorToken=${config.sponsorToken}`] : [],
|
|
30
|
+
...config.debug ? [`debug=${config.debug}`] : [],
|
|
31
|
+
...config.logging ? [`logging=${config.logging}`] : []
|
|
39
32
|
];
|
|
40
|
-
if (config.devMode) {
|
|
41
|
-
rawParams.push(param("apiUrl", config.apiUrl));
|
|
42
|
-
rawParams.push(param("relayerUrl", config.relayerUrl));
|
|
43
|
-
}
|
|
44
|
-
const params = rawParams.filter((value) => Boolean(value));
|
|
45
33
|
return {
|
|
46
34
|
origin,
|
|
47
35
|
uiUrl: `${origin}?${params.join("&")}`
|
package/package.json
CHANGED
|
@@ -1,70 +1,68 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"dist"
|
|
18
|
-
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
21
|
-
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
22
|
-
"dev:link": "pnpm build && pnpm link --global",
|
|
23
|
-
"test": "vitest",
|
|
24
|
-
"test:ui": "vitest --ui",
|
|
25
|
-
"test:coverage": "vitest --coverage",
|
|
26
|
-
"lint": "biome lint ./src",
|
|
27
|
-
"format": "biome format --write ./src",
|
|
28
|
-
"check": "biome check ./src",
|
|
29
|
-
"typecheck": "tsc --noEmit",
|
|
30
|
-
"prepare": "husky"
|
|
31
|
-
},
|
|
32
|
-
"keywords": [
|
|
33
|
-
"megaeth",
|
|
34
|
-
"wallet",
|
|
35
|
-
"sdk",
|
|
36
|
-
"web3"
|
|
37
|
-
],
|
|
38
|
-
"author": "",
|
|
39
|
-
"license": "MIT",
|
|
40
|
-
"repository": {
|
|
41
|
-
"type": "git",
|
|
42
|
-
"url": "git+https://github.com/megaeth-labs/wallet-sdk.git"
|
|
43
|
-
},
|
|
44
|
-
"sideEffects": false,
|
|
45
|
-
"publishConfig": {
|
|
46
|
-
"registry": "https://registry.npmjs.org/",
|
|
47
|
-
"access": "restricted"
|
|
48
|
-
},
|
|
49
|
-
"packageManager": "pnpm@10.29.2",
|
|
50
|
-
"dependencies": {
|
|
51
|
-
"penpal": "7.0.6"
|
|
52
|
-
},
|
|
53
|
-
"devDependencies": {
|
|
54
|
-
"@biomejs/biome": "2.4.6",
|
|
55
|
-
"@types/node": "25.3.5",
|
|
56
|
-
"@vitest/coverage-v8": "4.0.18",
|
|
57
|
-
"@vitest/ui": "4.0.18",
|
|
58
|
-
"husky": "^9.1.7",
|
|
59
|
-
"jsdom": "28.1.0",
|
|
60
|
-
"lint-staged": "^16.4.0",
|
|
61
|
-
"tsup": "8.5.1",
|
|
62
|
-
"typescript": "5.9.3",
|
|
63
|
-
"vitest": "4.0.18"
|
|
64
|
-
},
|
|
65
|
-
"lint-staged": {
|
|
66
|
-
"src/**/*.{ts,js,json}": [
|
|
67
|
-
"pnpm format"
|
|
68
|
-
]
|
|
2
|
+
"name": "@megaeth-labs/wallet-sdk",
|
|
3
|
+
"version": "0.1.16-beta.1",
|
|
4
|
+
"description": "MegaETH Wallet SDK for web applications",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
69
14
|
}
|
|
70
|
-
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"megaeth",
|
|
21
|
+
"wallet",
|
|
22
|
+
"sdk",
|
|
23
|
+
"web3"
|
|
24
|
+
],
|
|
25
|
+
"author": "",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/megaeth-labs/wallet-sdk.git"
|
|
30
|
+
},
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"registry": "https://registry.npmjs.org/",
|
|
34
|
+
"access": "restricted"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"penpal": "7.0.6"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@biomejs/biome": "2.4.6",
|
|
41
|
+
"@types/node": "25.3.5",
|
|
42
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
43
|
+
"@vitest/ui": "4.0.18",
|
|
44
|
+
"husky": "^9.1.7",
|
|
45
|
+
"jsdom": "28.1.0",
|
|
46
|
+
"lint-staged": "^16.4.0",
|
|
47
|
+
"tsup": "8.5.1",
|
|
48
|
+
"typescript": "5.9.3",
|
|
49
|
+
"vitest": "4.0.18"
|
|
50
|
+
},
|
|
51
|
+
"lint-staged": {
|
|
52
|
+
"src/**/*.{ts,js,json}": [
|
|
53
|
+
"pnpm format"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
58
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
59
|
+
"dev:link": "pnpm build && pnpm link --global",
|
|
60
|
+
"test": "vitest",
|
|
61
|
+
"test:ui": "vitest --ui",
|
|
62
|
+
"test:coverage": "vitest --coverage",
|
|
63
|
+
"lint": "biome lint ./src",
|
|
64
|
+
"format": "biome format --write ./src",
|
|
65
|
+
"check": "biome check ./src",
|
|
66
|
+
"typecheck": "tsc --noEmit"
|
|
67
|
+
}
|
|
68
|
+
}
|