viem 0.0.0-main.20240402T193836 → 0.0.0-main.20240402T202653
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/_cjs/errors/version.js +1 -1
- package/_cjs/experimental/actions/getCallsStatus.js +21 -0
- package/_cjs/experimental/actions/getCallsStatus.js.map +1 -0
- package/_cjs/experimental/actions/getCapabilities.js +14 -0
- package/_cjs/experimental/actions/getCapabilities.js.map +1 -0
- package/_cjs/experimental/actions/sendCalls.js +42 -0
- package/_cjs/experimental/actions/sendCalls.js.map +1 -0
- package/_cjs/experimental/decorators/eip5792.js +17 -0
- package/_cjs/experimental/decorators/eip5792.js.map +1 -0
- package/_cjs/experimental/index.js +12 -0
- package/_cjs/experimental/index.js.map +1 -0
- package/_esm/errors/version.js +1 -1
- package/_esm/experimental/actions/getCallsStatus.js +37 -0
- package/_esm/experimental/actions/getCallsStatus.js.map +1 -0
- package/_esm/experimental/actions/getCapabilities.js +30 -0
- package/_esm/experimental/actions/getCapabilities.js.map +1 -0
- package/_esm/experimental/actions/sendCalls.js +70 -0
- package/_esm/experimental/actions/sendCalls.js.map +1 -0
- package/_esm/experimental/decorators/eip5792.js +30 -0
- package/_esm/experimental/decorators/eip5792.js.map +1 -0
- package/_esm/experimental/index.js +5 -0
- package/_esm/experimental/index.js.map +1 -0
- package/_types/errors/version.d.ts +1 -1
- package/_types/experimental/actions/getCallsStatus.d.ts +35 -0
- package/_types/experimental/actions/getCallsStatus.d.ts.map +1 -0
- package/_types/experimental/actions/getCapabilities.d.ts +32 -0
- package/_types/experimental/actions/getCapabilities.d.ts.map +1 -0
- package/_types/experimental/actions/sendCalls.d.ts +56 -0
- package/_types/experimental/actions/sendCalls.d.ts.map +1 -0
- package/_types/experimental/decorators/eip5792.d.ts +106 -0
- package/_types/experimental/decorators/eip5792.d.ts.map +1 -0
- package/_types/experimental/index.d.ts +5 -0
- package/_types/experimental/index.d.ts.map +1 -0
- package/_types/types/eip1193.d.ts +69 -0
- package/_types/types/eip1193.d.ts.map +1 -1
- package/errors/version.ts +1 -1
- package/experimental/actions/getCallsStatus.ts +60 -0
- package/experimental/actions/getCapabilities.ts +56 -0
- package/experimental/actions/sendCalls.ts +126 -0
- package/experimental/decorators/eip5792.ts +139 -0
- package/experimental/index.ts +22 -0
- package/experimental/package.json +6 -0
- package/package.json +9 -1
- package/types/eip1193.ts +81 -0
package/_cjs/errors/version.js
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getCallsStatus = void 0;
|
4
|
+
const fromHex_js_1 = require("../../utils/encoding/fromHex.js");
|
5
|
+
async function getCallsStatus(client, parameters) {
|
6
|
+
const { id } = parameters;
|
7
|
+
const { receipts, status } = await client.request({
|
8
|
+
method: 'wallet_getCallsStatus',
|
9
|
+
params: id,
|
10
|
+
});
|
11
|
+
return {
|
12
|
+
status,
|
13
|
+
receipts: receipts?.map((receipt) => ({
|
14
|
+
...receipt,
|
15
|
+
blockNumber: (0, fromHex_js_1.hexToBigInt)(receipt.blockNumber),
|
16
|
+
gasUsed: (0, fromHex_js_1.hexToBigInt)(receipt.gasUsed),
|
17
|
+
})) ?? [],
|
18
|
+
};
|
19
|
+
}
|
20
|
+
exports.getCallsStatus = getCallsStatus;
|
21
|
+
//# sourceMappingURL=getCallsStatus.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../experimental/actions/getCallsStatus.ts"],"names":[],"mappings":";;;AAQA,gEAA6D;AA8BtD,KAAK,UAAU,cAAc,CAIlC,MAAyC,EACzC,UAAoC;IAEpC,MAAM,EAAE,EAAE,EAAE,GAAG,UAAU,CAAA;IACzB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAChD,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,EAAE;KACX,CAAC,CAAA;IACF,OAAO;QACL,MAAM;QACN,QAAQ,EACN,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAC1B,GAAG,OAAO;YACV,WAAW,EAAE,IAAA,wBAAW,EAAC,OAAO,CAAC,WAAW,CAAC;YAC7C,OAAO,EAAE,IAAA,wBAAW,EAAC,OAAO,CAAC,OAAO,CAAC;SACtC,CAAC,CAAC,IAAI,EAAE;KACZ,CAAA;AACH,CAAC;AArBD,wCAqBC"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getCapabilities = void 0;
|
4
|
+
async function getCapabilities(client) {
|
5
|
+
const capabilities_raw = await client.request({
|
6
|
+
method: 'wallet_getCapabilities',
|
7
|
+
});
|
8
|
+
const capabilities = {};
|
9
|
+
for (const [key, value] of Object.entries(capabilities_raw))
|
10
|
+
capabilities[Number(key)] = value;
|
11
|
+
return capabilities;
|
12
|
+
}
|
13
|
+
exports.getCapabilities = getCapabilities;
|
14
|
+
//# sourceMappingURL=getCapabilities.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getCapabilities.js","sourceRoot":"","sources":["../../../experimental/actions/getCapabilities.ts"],"names":[],"mappings":";;;AAsCO,KAAK,UAAU,eAAe,CAInC,MAAyC;IAEzC,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAC5C,MAAM,EAAE,wBAAwB;KACjC,CAAC,CAAA;IAEF,MAAM,YAAY,GAAG,EAGpB,CAAA;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC;QACzD,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAA;IACnC,OAAO,YAAY,CAAA;AACrB,CAAC;AAjBD,0CAiBC"}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.sendCalls = void 0;
|
4
|
+
const account_js_1 = require("../../errors/account.js");
|
5
|
+
const chain_js_1 = require("../../errors/chain.js");
|
6
|
+
const accounts_js_1 = require("../../utils/accounts.js");
|
7
|
+
const toHex_js_1 = require("../../utils/encoding/toHex.js");
|
8
|
+
const index_js_1 = require("../../utils/index.js");
|
9
|
+
async function sendCalls(client, parameters) {
|
10
|
+
const { account: account_ = client.account, calls, capabilities, chain = client.chain, version = '1.0', } = parameters;
|
11
|
+
if (!account_)
|
12
|
+
throw new account_js_1.AccountNotFoundError({
|
13
|
+
docsPath: '/eip5792/actions/sendCalls',
|
14
|
+
});
|
15
|
+
const account = (0, accounts_js_1.parseAccount)(account_);
|
16
|
+
if (!chain)
|
17
|
+
throw new chain_js_1.ChainNotFoundError();
|
18
|
+
try {
|
19
|
+
return await client.request({
|
20
|
+
method: 'wallet_sendCalls',
|
21
|
+
params: {
|
22
|
+
calls: calls.map((call) => ({
|
23
|
+
...call,
|
24
|
+
value: call.value ? (0, toHex_js_1.numberToHex)(call.value) : undefined,
|
25
|
+
})),
|
26
|
+
capabilities,
|
27
|
+
chainId: (0, toHex_js_1.numberToHex)(chain.id),
|
28
|
+
from: account.address,
|
29
|
+
version,
|
30
|
+
},
|
31
|
+
}, { retryCount: 0 });
|
32
|
+
}
|
33
|
+
catch (err) {
|
34
|
+
throw (0, index_js_1.getTransactionError)(err, {
|
35
|
+
...parameters,
|
36
|
+
account,
|
37
|
+
chain: parameters.chain,
|
38
|
+
});
|
39
|
+
}
|
40
|
+
}
|
41
|
+
exports.sendCalls = sendCalls;
|
42
|
+
//# sourceMappingURL=sendCalls.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sendCalls.js","sourceRoot":"","sources":["../../../experimental/actions/sendCalls.ts"],"names":[],"mappings":";;;AAEA,wDAA8D;AAE9D,oDAA0D;AAU1D,yD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@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.walletActionsEip5792 = void 0;
|
4
|
+
const getCallsStatus_js_1 = require("../actions/getCallsStatus.js");
|
5
|
+
const getCapabilities_js_1 = require("../actions/getCapabilities.js");
|
6
|
+
const sendCalls_js_1 = require("../actions/sendCalls.js");
|
7
|
+
function walletActionsEip5792() {
|
8
|
+
return (client) => {
|
9
|
+
return {
|
10
|
+
getCallsStatus: (parameters) => (0, getCallsStatus_js_1.getCallsStatus)(client, parameters),
|
11
|
+
getCapabilities: () => (0, getCapabilities_js_1.getCapabilities)(client),
|
12
|
+
sendCalls: (parameters) => (0, sendCalls_js_1.sendCalls)(client, parameters),
|
13
|
+
};
|
14
|
+
};
|
15
|
+
}
|
16
|
+
exports.walletActionsEip5792 = walletActionsEip5792;
|
17
|
+
//# sourceMappingURL=eip5792.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"eip5792.js","sourceRoot":"","sources":["../../../experimental/decorators/eip5792.ts"],"names":[],"mappings":";;;AAIA,oEAIqC;AACrC,sEAGsC;AACtC,0DAIgC;AA2GhC,SAAgB,oBAAoB;IAClC,OAAO,CAKL,MAAyC,EACH,EAAE;QACxC,OAAO;YACL,cAAc,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,IAAA,kCAAc,EAAC,MAAM,EAAE,UAAU,CAAC;YAClE,eAAe,EAAE,GAAG,EAAE,CAAC,IAAA,oCAAe,EAAC,MAAM,CAAC;YAC9C,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,IAAA,wBAAS,EAAC,MAAM,EAAE,UAAU,CAAC;SACzD,CAAA;IACH,CAAC,CAAA;AACH,CAAC;AAdD,oDAcC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.walletActionsEip5792 = exports.getCallsStatus = exports.sendCalls = exports.getCapabilities = void 0;
|
4
|
+
var getCapabilities_js_1 = require("./actions/getCapabilities.js");
|
5
|
+
Object.defineProperty(exports, "getCapabilities", { enumerable: true, get: function () { return getCapabilities_js_1.getCapabilities; } });
|
6
|
+
var sendCalls_js_1 = require("./actions/sendCalls.js");
|
7
|
+
Object.defineProperty(exports, "sendCalls", { enumerable: true, get: function () { return sendCalls_js_1.sendCalls; } });
|
8
|
+
var getCallsStatus_js_1 = require("./actions/getCallsStatus.js");
|
9
|
+
Object.defineProperty(exports, "getCallsStatus", { enumerable: true, get: function () { return getCallsStatus_js_1.getCallsStatus; } });
|
10
|
+
var eip5792_js_1 = require("./decorators/eip5792.js");
|
11
|
+
Object.defineProperty(exports, "walletActionsEip5792", { enumerable: true, get: function () { return eip5792_js_1.walletActionsEip5792; } });
|
12
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../experimental/index.ts"],"names":[],"mappings":";;;AAAA,mEAIqC;AADnC,qHAAA,eAAe,OAAA;AAEjB,uDAK+B;AAD7B,yGAAA,SAAS,OAAA;AAEX,iEAKoC;AADlC,mHAAA,cAAc,OAAA;AAGhB,sDAGgC;AAD9B,kHAAA,oBAAoB,OAAA"}
|
package/_esm/errors/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export const version = '0.0.0-main.
|
1
|
+
export const version = '0.0.0-main.20240402T202653';
|
2
2
|
//# sourceMappingURL=version.js.map
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { hexToBigInt } from '../../utils/encoding/fromHex.js';
|
2
|
+
/**
|
3
|
+
* Returns the status of a call batch that was sent via `sendCalls`.
|
4
|
+
*
|
5
|
+
* - Docs: https://viem.sh/eip5792/actions/getCallsStatus
|
6
|
+
* - JSON-RPC Methods: [`wallet_getCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
|
7
|
+
*
|
8
|
+
* @param client - Client to use
|
9
|
+
* @returns Status of the calls. {@link GetCallsStatusReturnType}
|
10
|
+
*
|
11
|
+
* @example
|
12
|
+
* import { createWalletClient, custom } from 'viem'
|
13
|
+
* import { mainnet } from 'viem/chains'
|
14
|
+
* import { getCallsStatus } from 'viem/wallet'
|
15
|
+
*
|
16
|
+
* const client = createWalletClient({
|
17
|
+
* chain: mainnet,
|
18
|
+
* transport: custom(window.ethereum),
|
19
|
+
* })
|
20
|
+
* const { receipts, status } = await getCallsStatus(client, { id: '0xdeadbeef' })
|
21
|
+
*/
|
22
|
+
export async function getCallsStatus(client, parameters) {
|
23
|
+
const { id } = parameters;
|
24
|
+
const { receipts, status } = await client.request({
|
25
|
+
method: 'wallet_getCallsStatus',
|
26
|
+
params: id,
|
27
|
+
});
|
28
|
+
return {
|
29
|
+
status,
|
30
|
+
receipts: receipts?.map((receipt) => ({
|
31
|
+
...receipt,
|
32
|
+
blockNumber: hexToBigInt(receipt.blockNumber),
|
33
|
+
gasUsed: hexToBigInt(receipt.gasUsed),
|
34
|
+
})) ?? [],
|
35
|
+
};
|
36
|
+
}
|
37
|
+
//# sourceMappingURL=getCallsStatus.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../experimental/actions/getCallsStatus.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAU7D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAIlC,MAAyC,EACzC,UAAoC;IAEpC,MAAM,EAAE,EAAE,EAAE,GAAG,UAAU,CAAA;IACzB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAChD,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,EAAE;KACX,CAAC,CAAA;IACF,OAAO;QACL,MAAM;QACN,QAAQ,EACN,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAC1B,GAAG,OAAO;YACV,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC;YAC7C,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC;SACtC,CAAC,CAAC,IAAI,EAAE;KACZ,CAAA;AACH,CAAC"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/**
|
2
|
+
* Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc).
|
3
|
+
*
|
4
|
+
* - Docs: https://viem.sh/eip5792/actions/getCapabilities
|
5
|
+
* - JSON-RPC Methods: [`wallet_getCapabilities`](https://eips.ethereum.org/EIPS/eip-5792)
|
6
|
+
*
|
7
|
+
* @param client - Client to use
|
8
|
+
* @returns The wallet's capabilities. {@link GetCapabilitiesReturnType}
|
9
|
+
*
|
10
|
+
* @example
|
11
|
+
* import { createWalletClient, custom } from 'viem'
|
12
|
+
* import { mainnet } from 'viem/chains'
|
13
|
+
* import { getCapabilities } from 'viem/wallet'
|
14
|
+
*
|
15
|
+
* const client = createWalletClient({
|
16
|
+
* chain: mainnet,
|
17
|
+
* transport: custom(window.ethereum),
|
18
|
+
* })
|
19
|
+
* const capabilities = await getCapabilities(client)
|
20
|
+
*/
|
21
|
+
export async function getCapabilities(client) {
|
22
|
+
const capabilities_raw = await client.request({
|
23
|
+
method: 'wallet_getCapabilities',
|
24
|
+
});
|
25
|
+
const capabilities = {};
|
26
|
+
for (const [key, value] of Object.entries(capabilities_raw))
|
27
|
+
capabilities[Number(key)] = value;
|
28
|
+
return capabilities;
|
29
|
+
}
|
30
|
+
//# sourceMappingURL=getCapabilities.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getCapabilities.js","sourceRoot":"","sources":["../../../experimental/actions/getCapabilities.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAInC,MAAyC;IAEzC,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAC5C,MAAM,EAAE,wBAAwB;KACjC,CAAC,CAAA;IAEF,MAAM,YAAY,GAAG,EAGpB,CAAA;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC;QACzD,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAA;IACnC,OAAO,YAAY,CAAA;AACrB,CAAC"}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import { AccountNotFoundError } from '../../errors/account.js';
|
2
|
+
import { ChainNotFoundError } from '../../errors/chain.js';
|
3
|
+
import { parseAccount } from '../../utils/accounts.js';
|
4
|
+
import { numberToHex } from '../../utils/encoding/toHex.js';
|
5
|
+
import { getTransactionError } from '../../utils/index.js';
|
6
|
+
/**
|
7
|
+
* Requests the connected wallet to send a batch of calls.
|
8
|
+
*
|
9
|
+
* - Docs: https://viem.sh/eip5792/actions/sendCalls
|
10
|
+
* - JSON-RPC Methods: [`wallet_sendCalls`](https://eips.ethereum.org/EIPS/eip-5792)
|
11
|
+
*
|
12
|
+
* @param client - Client to use
|
13
|
+
* @returns Transaction identifier. {@link SendCallsReturnType}
|
14
|
+
*
|
15
|
+
* @example
|
16
|
+
* import { createWalletClient, custom } from 'viem'
|
17
|
+
* import { mainnet } from 'viem/chains'
|
18
|
+
* import { sendCalls } from 'viem/wallet'
|
19
|
+
*
|
20
|
+
* const client = createWalletClient({
|
21
|
+
* chain: mainnet,
|
22
|
+
* transport: custom(window.ethereum),
|
23
|
+
* })
|
24
|
+
* const id = await sendCalls(client, {
|
25
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
26
|
+
* calls: [
|
27
|
+
* {
|
28
|
+
* data: '0xdeadbeef',
|
29
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
30
|
+
* },
|
31
|
+
* {
|
32
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
33
|
+
* value: 69420n,
|
34
|
+
* },
|
35
|
+
* ],
|
36
|
+
* })
|
37
|
+
*/
|
38
|
+
export async function sendCalls(client, parameters) {
|
39
|
+
const { account: account_ = client.account, calls, capabilities, chain = client.chain, version = '1.0', } = parameters;
|
40
|
+
if (!account_)
|
41
|
+
throw new AccountNotFoundError({
|
42
|
+
docsPath: '/eip5792/actions/sendCalls',
|
43
|
+
});
|
44
|
+
const account = parseAccount(account_);
|
45
|
+
if (!chain)
|
46
|
+
throw new ChainNotFoundError();
|
47
|
+
try {
|
48
|
+
return await client.request({
|
49
|
+
method: 'wallet_sendCalls',
|
50
|
+
params: {
|
51
|
+
calls: calls.map((call) => ({
|
52
|
+
...call,
|
53
|
+
value: call.value ? numberToHex(call.value) : undefined,
|
54
|
+
})),
|
55
|
+
capabilities,
|
56
|
+
chainId: numberToHex(chain.id),
|
57
|
+
from: account.address,
|
58
|
+
version,
|
59
|
+
},
|
60
|
+
}, { retryCount: 0 });
|
61
|
+
}
|
62
|
+
catch (err) {
|
63
|
+
throw getTransactionError(err, {
|
64
|
+
...parameters,
|
65
|
+
account,
|
66
|
+
chain: parameters.chain,
|
67
|
+
});
|
68
|
+
}
|
69
|
+
}
|
70
|
+
//# sourceMappingURL=sendCalls.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sendCalls.js","sourceRoot":"","sources":["../../../experimental/actions/sendCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAU1D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AA4B1D;;;;;;;;;;;;;;;;;;;;;;;;;;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.js';
|
2
|
+
import { getCapabilities, } from '../actions/getCapabilities.js';
|
3
|
+
import { sendCalls, } from '../actions/sendCalls.js';
|
4
|
+
/**
|
5
|
+
* A suite of EIP-5792 Wallet Actions.
|
6
|
+
*
|
7
|
+
* - Docs: https://viem.sh/eip5792
|
8
|
+
*
|
9
|
+
* @example
|
10
|
+
* import { createPublicClient, createWalletClient, http } from 'viem'
|
11
|
+
* import { mainnet } from 'viem/chains'
|
12
|
+
* import { walletActionsEip5792 } from 'viem/experimental'
|
13
|
+
*
|
14
|
+
* const walletClient = createWalletClient({
|
15
|
+
* chain: mainnet,
|
16
|
+
* transport: http(),
|
17
|
+
* }).extend(walletActionsEip5792())
|
18
|
+
*
|
19
|
+
* const hash = await walletClient.sendCalls({...})
|
20
|
+
*/
|
21
|
+
export function walletActionsEip5792() {
|
22
|
+
return (client) => {
|
23
|
+
return {
|
24
|
+
getCallsStatus: (parameters) => getCallsStatus(client, parameters),
|
25
|
+
getCapabilities: () => getCapabilities(client),
|
26
|
+
sendCalls: (parameters) => sendCalls(client, parameters),
|
27
|
+
};
|
28
|
+
};
|
29
|
+
}
|
30
|
+
//# sourceMappingURL=eip5792.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"eip5792.js","sourceRoot":"","sources":["../../../experimental/decorators/eip5792.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,cAAc,GACf,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAEL,eAAe,GAChB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAGL,SAAS,GACV,MAAM,yBAAyB,CAAA;AA0FhC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,CAKL,MAAyC,EACH,EAAE;QACxC,OAAO;YACL,cAAc,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC;YAClE,eAAe,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC;YAC9C,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;SACzD,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export { getCapabilities, } from './actions/getCapabilities.js';
|
2
|
+
export { sendCalls, } from './actions/sendCalls.js';
|
3
|
+
export { getCallsStatus, } from './actions/getCallsStatus.js';
|
4
|
+
export { walletActionsEip5792, } from './decorators/eip5792.js';
|
5
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../experimental/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,GAChB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAIL,SAAS,GACV,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAIL,cAAc,GACf,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAEL,oBAAoB,GACrB,MAAM,yBAAyB,CAAA"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "0.0.0-main.
|
1
|
+
export declare const version = "0.0.0-main.20240402T202653";
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import type { Client } from '../../clients/createClient.js';
|
2
|
+
import type { Transport } from '../../clients/transports/createTransport.js';
|
3
|
+
import type { ErrorType } from '../../errors/utils.js';
|
4
|
+
import type { Account } from '../../types/account.js';
|
5
|
+
import type { Chain } from '../../types/chain.js';
|
6
|
+
import type { WalletGetCallsStatusReturnType } from '../../types/eip1193.js';
|
7
|
+
import type { Prettify } from '../../types/utils.js';
|
8
|
+
import type { RequestErrorType } from '../../utils/buildRequest.js';
|
9
|
+
export type GetCallsStatusParameters = {
|
10
|
+
id: string;
|
11
|
+
};
|
12
|
+
export type GetCallsStatusReturnType = Prettify<WalletGetCallsStatusReturnType<bigint>>;
|
13
|
+
export type GetCallsStatusErrorType = RequestErrorType | ErrorType;
|
14
|
+
/**
|
15
|
+
* Returns the status of a call batch that was sent via `sendCalls`.
|
16
|
+
*
|
17
|
+
* - Docs: https://viem.sh/eip5792/actions/getCallsStatus
|
18
|
+
* - JSON-RPC Methods: [`wallet_getCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
|
19
|
+
*
|
20
|
+
* @param client - Client to use
|
21
|
+
* @returns Status of the calls. {@link GetCallsStatusReturnType}
|
22
|
+
*
|
23
|
+
* @example
|
24
|
+
* import { createWalletClient, custom } from 'viem'
|
25
|
+
* import { mainnet } from 'viem/chains'
|
26
|
+
* import { getCallsStatus } from 'viem/wallet'
|
27
|
+
*
|
28
|
+
* const client = createWalletClient({
|
29
|
+
* chain: mainnet,
|
30
|
+
* transport: custom(window.ethereum),
|
31
|
+
* })
|
32
|
+
* const { receipts, status } = await getCallsStatus(client, { id: '0xdeadbeef' })
|
33
|
+
*/
|
34
|
+
export declare function getCallsStatus<chain extends Chain | undefined, account extends Account | undefined = undefined>(client: Client<Transport, chain, account>, parameters: GetCallsStatusParameters): Promise<GetCallsStatusReturnType>;
|
35
|
+
//# sourceMappingURL=getCallsStatus.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getCallsStatus.d.ts","sourceRoot":"","sources":["../../../experimental/actions/getCallsStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAA;AAC5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAGnE,MAAM,MAAM,wBAAwB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAErD,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAC7C,8BAA8B,CAAC,MAAM,CAAC,CACvC,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,gBAAgB,GAAG,SAAS,CAAA;AAElE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,cAAc,CAClC,KAAK,SAAS,KAAK,GAAG,SAAS,EAC/B,OAAO,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAE/C,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,EACzC,UAAU,EAAE,wBAAwB,GACnC,OAAO,CAAC,wBAAwB,CAAC,CAenC"}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import type { Client } from '../../clients/createClient.js';
|
2
|
+
import type { Transport } from '../../clients/transports/createTransport.js';
|
3
|
+
import type { ErrorType } from '../../errors/utils.js';
|
4
|
+
import type { Account } from '../../types/account.js';
|
5
|
+
import type { Chain } from '../../types/chain.js';
|
6
|
+
import type { WalletCapabilities, WalletCapabilitiesRecord } from '../../types/eip1193.js';
|
7
|
+
import type { Prettify } from '../../types/utils.js';
|
8
|
+
import type { RequestErrorType } from '../../utils/buildRequest.js';
|
9
|
+
export type GetCapabilitiesReturnType = Prettify<WalletCapabilitiesRecord<WalletCapabilities, number>>;
|
10
|
+
export type GetCapabilitiesErrorType = RequestErrorType | ErrorType;
|
11
|
+
/**
|
12
|
+
* Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc).
|
13
|
+
*
|
14
|
+
* - Docs: https://viem.sh/eip5792/actions/getCapabilities
|
15
|
+
* - JSON-RPC Methods: [`wallet_getCapabilities`](https://eips.ethereum.org/EIPS/eip-5792)
|
16
|
+
*
|
17
|
+
* @param client - Client to use
|
18
|
+
* @returns The wallet's capabilities. {@link GetCapabilitiesReturnType}
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* import { createWalletClient, custom } from 'viem'
|
22
|
+
* import { mainnet } from 'viem/chains'
|
23
|
+
* import { getCapabilities } from 'viem/wallet'
|
24
|
+
*
|
25
|
+
* const client = createWalletClient({
|
26
|
+
* chain: mainnet,
|
27
|
+
* transport: custom(window.ethereum),
|
28
|
+
* })
|
29
|
+
* const capabilities = await getCapabilities(client)
|
30
|
+
*/
|
31
|
+
export declare function getCapabilities<chain extends Chain | undefined, account extends Account | undefined = undefined>(client: Client<Transport, chain, account>): Promise<GetCapabilitiesReturnType>;
|
32
|
+
//# sourceMappingURL=getCapabilities.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getCapabilities.d.ts","sourceRoot":"","sources":["../../../experimental/actions/getCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EACV,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAEnE,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAC9C,wBAAwB,CAAC,kBAAkB,EAAE,MAAM,CAAC,CACrD,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG,SAAS,CAAA;AAEnE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,eAAe,CACnC,KAAK,SAAS,KAAK,GAAG,SAAS,EAC/B,OAAO,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAE/C,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,GACxC,OAAO,CAAC,yBAAyB,CAAC,CAYpC"}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import type { Client } from '../../clients/createClient.js';
|
2
|
+
import type { Transport } from '../../clients/transports/createTransport.js';
|
3
|
+
import type { ErrorType } from '../../errors/utils.js';
|
4
|
+
import type { Account, GetAccountParameter } from '../../types/account.js';
|
5
|
+
import type { Chain, GetChainParameter } from '../../types/chain.js';
|
6
|
+
import type { WalletCapabilities, WalletSendCallsParameters } from '../../types/eip1193.js';
|
7
|
+
import type { Hex } from '../../types/misc.js';
|
8
|
+
import type { OneOf } from '../../types/utils.js';
|
9
|
+
import type { RequestErrorType } from '../../utils/buildRequest.js';
|
10
|
+
export type SendCallsParameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined, chainOverride extends Chain | undefined = Chain | undefined> = {
|
11
|
+
calls: OneOf<{
|
12
|
+
to: Hex;
|
13
|
+
data?: Hex;
|
14
|
+
value?: bigint;
|
15
|
+
} | {
|
16
|
+
data: Hex;
|
17
|
+
}>[];
|
18
|
+
capabilities?: WalletSendCallsParameters<WalletCapabilities>['capabilities'] | undefined;
|
19
|
+
version?: WalletSendCallsParameters['version'] | undefined;
|
20
|
+
} & GetAccountParameter<account> & GetChainParameter<chain, chainOverride>;
|
21
|
+
export type SendCallsReturnType = string;
|
22
|
+
export type SendCallsErrorType = RequestErrorType | ErrorType;
|
23
|
+
/**
|
24
|
+
* Requests the connected wallet to send a batch of calls.
|
25
|
+
*
|
26
|
+
* - Docs: https://viem.sh/eip5792/actions/sendCalls
|
27
|
+
* - JSON-RPC Methods: [`wallet_sendCalls`](https://eips.ethereum.org/EIPS/eip-5792)
|
28
|
+
*
|
29
|
+
* @param client - Client to use
|
30
|
+
* @returns Transaction identifier. {@link SendCallsReturnType}
|
31
|
+
*
|
32
|
+
* @example
|
33
|
+
* import { createWalletClient, custom } from 'viem'
|
34
|
+
* import { mainnet } from 'viem/chains'
|
35
|
+
* import { sendCalls } from 'viem/wallet'
|
36
|
+
*
|
37
|
+
* const client = createWalletClient({
|
38
|
+
* chain: mainnet,
|
39
|
+
* transport: custom(window.ethereum),
|
40
|
+
* })
|
41
|
+
* const id = await sendCalls(client, {
|
42
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
43
|
+
* calls: [
|
44
|
+
* {
|
45
|
+
* data: '0xdeadbeef',
|
46
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
47
|
+
* },
|
48
|
+
* {
|
49
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
50
|
+
* value: 69420n,
|
51
|
+
* },
|
52
|
+
* ],
|
53
|
+
* })
|
54
|
+
*/
|
55
|
+
export declare function sendCalls<chain extends Chain | undefined, account extends Account | undefined = undefined, chainOverride extends Chain | undefined = undefined>(client: Client<Transport, chain, account>, parameters: SendCallsParameters<chain, account, chainOverride>): Promise<SendCallsReturnType>;
|
56
|
+
//# sourceMappingURL=sendCalls.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sendCalls.d.ts","sourceRoot":"","sources":["../../../experimental/actions/sendCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AAI5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC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AAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,EACzC,UAAU,EAAE,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,GAC7D,OAAO,CAAC,mBAAmB,CAAC,CAyC9B"}
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import type { Client } from '../../clients/createClient.js';
|
2
|
+
import type { Transport } from '../../clients/transports/createTransport.js';
|
3
|
+
import type { Account } from '../../types/account.js';
|
4
|
+
import type { Chain } from '../../types/chain.js';
|
5
|
+
import { type GetCallsStatusParameters, type GetCallsStatusReturnType } from '../actions/getCallsStatus.js';
|
6
|
+
import { type GetCapabilitiesReturnType } from '../actions/getCapabilities.js';
|
7
|
+
import { type SendCallsParameters, type SendCallsReturnType } from '../actions/sendCalls.js';
|
8
|
+
export type WalletActionsEip5792<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = {
|
9
|
+
/**
|
10
|
+
* Returns the status of a call batch that was sent via `sendCalls`.
|
11
|
+
*
|
12
|
+
* - Docs: https://viem.sh/eip5792/actions/getCallsStatus
|
13
|
+
* - JSON-RPC Methods: [`wallet_getCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
|
14
|
+
*
|
15
|
+
* @param client - Client to use
|
16
|
+
* @returns Status of the calls. {@link GetCallsStatusReturnType}
|
17
|
+
*
|
18
|
+
* @example
|
19
|
+
* import { createWalletClient, custom } from 'viem'
|
20
|
+
* import { mainnet } from 'viem/chains'
|
21
|
+
* import { walletActionsEip5792 } from 'viem/experimental'
|
22
|
+
*
|
23
|
+
* const client = createWalletClient({
|
24
|
+
* chain: mainnet,
|
25
|
+
* transport: custom(window.ethereum),
|
26
|
+
* }).extend(walletActionsEip5792())
|
27
|
+
*
|
28
|
+
* const { receipts, status } = await client.getCallsStatus({ id: '0xdeadbeef' })
|
29
|
+
*/
|
30
|
+
getCallsStatus: (parameters: GetCallsStatusParameters) => Promise<GetCallsStatusReturnType>;
|
31
|
+
/**
|
32
|
+
* Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc).
|
33
|
+
*
|
34
|
+
* - Docs: https://viem.sh/eip5792/actions/getCapabilities
|
35
|
+
* - JSON-RPC Methods: [`wallet_getCapabilities`](https://eips.ethereum.org/EIPS/eip-5792)
|
36
|
+
*
|
37
|
+
* @param client - Client to use
|
38
|
+
* @returns The wallet's capabilities. {@link GetCapabilitiesReturnType}
|
39
|
+
*
|
40
|
+
* @example
|
41
|
+
* import { createWalletClient, custom } from 'viem'
|
42
|
+
* import { mainnet } from 'viem/chains'
|
43
|
+
* import { walletActionsEip5792 } from 'viem/experimental'
|
44
|
+
*
|
45
|
+
* const client = createWalletClient({
|
46
|
+
* chain: mainnet,
|
47
|
+
* transport: custom(window.ethereum),
|
48
|
+
* }).extend(walletActionsEip5792())
|
49
|
+
*
|
50
|
+
* const capabilities = await client.getCapabilities()
|
51
|
+
*/
|
52
|
+
getCapabilities: () => Promise<GetCapabilitiesReturnType>;
|
53
|
+
/**
|
54
|
+
* Requests the connected wallet to send a batch of calls.
|
55
|
+
*
|
56
|
+
* - Docs: https://viem.sh/eip5792/actions/sendCalls
|
57
|
+
* - JSON-RPC Methods: [`wallet_sendCalls`](https://eips.ethereum.org/EIPS/eip-5792)
|
58
|
+
*
|
59
|
+
* @param client - Client to use
|
60
|
+
* @returns Transaction identifier. {@link SendCallsReturnType}
|
61
|
+
*
|
62
|
+
* @example
|
63
|
+
* import { createWalletClient, custom } from 'viem'
|
64
|
+
* import { mainnet } from 'viem/chains'
|
65
|
+
* import { walletActionsEip5792 } from 'viem/experimental'
|
66
|
+
*
|
67
|
+
* const client = createWalletClient({
|
68
|
+
* chain: mainnet,
|
69
|
+
* transport: custom(window.ethereum),
|
70
|
+
* }).extend(walletActionsEip5792())
|
71
|
+
*
|
72
|
+
* const id = await client.sendCalls({
|
73
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
74
|
+
* calls: [
|
75
|
+
* {
|
76
|
+
* data: '0xdeadbeef',
|
77
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
78
|
+
* },
|
79
|
+
* {
|
80
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
81
|
+
* value: 69420n,
|
82
|
+
* },
|
83
|
+
* ],
|
84
|
+
* })
|
85
|
+
*/
|
86
|
+
sendCalls: <chainOverride extends Chain | undefined = undefined>(parameters: SendCallsParameters<chain, account, chainOverride>) => Promise<SendCallsReturnType>;
|
87
|
+
};
|
88
|
+
/**
|
89
|
+
* A suite of EIP-5792 Wallet Actions.
|
90
|
+
*
|
91
|
+
* - Docs: https://viem.sh/eip5792
|
92
|
+
*
|
93
|
+
* @example
|
94
|
+
* import { createPublicClient, createWalletClient, http } from 'viem'
|
95
|
+
* import { mainnet } from 'viem/chains'
|
96
|
+
* import { walletActionsEip5792 } from 'viem/experimental'
|
97
|
+
*
|
98
|
+
* const walletClient = createWalletClient({
|
99
|
+
* chain: mainnet,
|
100
|
+
* transport: http(),
|
101
|
+
* }).extend(walletActionsEip5792())
|
102
|
+
*
|
103
|
+
* const hash = await walletClient.sendCalls({...})
|
104
|
+
*/
|
105
|
+
export declare function walletActionsEip5792(): <transport extends Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined>(client: Client<transport, chain, account>) => WalletActionsEip5792<chain, account>;
|
106
|
+
//# sourceMappingURL=eip5792.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"eip5792.d.ts","sourceRoot":"","sources":["../../../experimental/decorators/eip5792.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAE9B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,KAAK,yBAAyB,EAE/B,MAAM,+BAA+B,CAAA;AACtC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAEzB,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,oBAAoB,CAC9B,KAAK,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACnD,OAAO,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,IACvD;IACF;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,cAAc,EAAE,CACd,UAAU,EAAE,wBAAwB,KACjC,OAAO,CAAC,wBAAwB,CAAC,CAAA;IACtC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,eAAe,EAAE,MAAM,OAAO,CAAC,yBAAyB,CAAC,CAAA;IACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,SAAS,EAAE,CAAC,aAAa,SAAS,KAAK,GAAG,SAAS,GAAG,SAAS,EAC7D,UAAU,EAAE,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,KAC3D,OAAO,CAAC,mBAAmB,CAAC,CAAA;CAClC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,0JAMxB,OAAO,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,KACxC,qBAAqB,KAAK,EAAE,OAAO,CAAC,CAOxC"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export { type GetCapabilitiesErrorType, type GetCapabilitiesReturnType, getCapabilities, } from './actions/getCapabilities.js';
|
2
|
+
export { type SendCallsErrorType, type SendCallsParameters, type SendCallsReturnType, sendCalls, } from './actions/sendCalls.js';
|
3
|
+
export { type GetCallsStatusErrorType, type GetCallsStatusParameters, type GetCallsStatusReturnType, getCallsStatus, } from './actions/getCallsStatus.js';
|
4
|
+
export { type WalletActionsEip5792, walletActionsEip5792, } from './decorators/eip5792.js';
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../experimental/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,eAAe,GAChB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,SAAS,GACV,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,cAAc,GACf,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EACL,KAAK,oBAAoB,EACzB,oBAAoB,GACrB,MAAM,yBAAyB,CAAA"}
|