tempo.ts 0.0.6 → 0.1.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/dist/chains.d.ts +244 -541
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +10 -23
- package/dist/chains.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ox/SignatureEnvelope.d.ts +245 -0
- package/dist/ox/SignatureEnvelope.d.ts.map +1 -0
- package/dist/ox/SignatureEnvelope.js +437 -0
- package/dist/ox/SignatureEnvelope.js.map +1 -0
- package/dist/ox/Transaction.d.ts +61 -24
- package/dist/ox/Transaction.d.ts.map +1 -1
- package/dist/ox/Transaction.js +63 -18
- package/dist/ox/Transaction.js.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.d.ts +461 -0
- package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -0
- package/dist/ox/TransactionEnvelopeAA.js +528 -0
- package/dist/ox/TransactionEnvelopeAA.js.map +1 -0
- package/dist/ox/TransactionRequest.d.ts +7 -5
- package/dist/ox/TransactionRequest.d.ts.map +1 -1
- package/dist/ox/TransactionRequest.js +21 -12
- package/dist/ox/TransactionRequest.js.map +1 -1
- package/dist/ox/index.d.ts +5 -4
- package/dist/ox/index.d.ts.map +1 -1
- package/dist/ox/index.js +5 -4
- package/dist/ox/index.js.map +1 -1
- package/dist/prool/Instance.d.ts +0 -4
- package/dist/prool/Instance.d.ts.map +1 -1
- package/dist/prool/Instance.js +7 -7
- package/dist/prool/Instance.js.map +1 -1
- package/dist/prool/index.d.ts +1 -1
- package/dist/prool/index.d.ts.map +1 -1
- package/dist/prool/index.js +1 -1
- package/dist/prool/index.js.map +1 -1
- package/dist/viem/{abis.d.ts → Abis.d.ts} +523 -9
- package/dist/viem/Abis.d.ts.map +1 -0
- package/dist/viem/{abis.js → Abis.js} +321 -9
- package/dist/viem/Abis.js.map +1 -0
- package/dist/viem/{actions → Actions}/amm.d.ts +21 -21
- package/dist/viem/Actions/amm.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/amm.js +55 -43
- package/dist/viem/Actions/amm.js.map +1 -0
- package/dist/viem/Actions/dex.d.ts +3263 -0
- package/dist/viem/Actions/dex.d.ts.map +1 -0
- package/dist/viem/Actions/dex.js +1357 -0
- package/dist/viem/Actions/dex.js.map +1 -0
- package/dist/viem/{actions → Actions}/fee.d.ts +8 -8
- package/dist/viem/Actions/fee.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/fee.js +14 -13
- package/dist/viem/Actions/fee.js.map +1 -0
- package/dist/viem/Actions/index.d.ts +6 -0
- package/dist/viem/Actions/index.d.ts.map +1 -0
- package/dist/viem/Actions/index.js +6 -0
- package/dist/viem/Actions/index.js.map +1 -0
- package/dist/viem/{actions → Actions}/policy.d.ts +19 -19
- package/dist/viem/Actions/policy.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/policy.js +59 -46
- package/dist/viem/Actions/policy.js.map +1 -0
- package/dist/viem/{actions → Actions}/token.d.ts +3275 -698
- package/dist/viem/Actions/token.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/token.js +458 -84
- package/dist/viem/Actions/token.js.map +1 -0
- package/dist/viem/Addresses.d.ts +9 -0
- package/dist/viem/Addresses.d.ts.map +1 -0
- package/dist/viem/Addresses.js +9 -0
- package/dist/viem/Addresses.js.map +1 -0
- package/dist/viem/{chain.d.ts → Chain.d.ts} +81 -57
- package/dist/viem/Chain.d.ts.map +1 -0
- package/dist/viem/{chain.js → Chain.js} +7 -7
- package/dist/viem/Chain.js.map +1 -0
- package/dist/viem/{client.d.ts → Client.d.ts} +4 -4
- package/dist/viem/Client.d.ts.map +1 -0
- package/dist/viem/{client.js → Client.js} +3 -3
- package/dist/viem/Client.js.map +1 -0
- package/dist/viem/{decorator.d.ts → Decorator.d.ts} +507 -5
- package/dist/viem/Decorator.d.ts.map +1 -0
- package/dist/viem/{decorator.js → Decorator.js} +31 -5
- package/dist/viem/Decorator.js.map +1 -0
- package/dist/viem/{formatters.d.ts → Formatters.d.ts} +2 -2
- package/dist/viem/Formatters.d.ts.map +1 -0
- package/dist/viem/{formatters.js → Formatters.js} +24 -17
- package/dist/viem/Formatters.js.map +1 -0
- package/dist/viem/Tick.d.ts +111 -0
- package/dist/viem/Tick.d.ts.map +1 -0
- package/dist/viem/Tick.js +127 -0
- package/dist/viem/Tick.js.map +1 -0
- package/dist/viem/TokenIds.d.ts +3 -0
- package/dist/viem/TokenIds.d.ts.map +1 -0
- package/dist/viem/TokenIds.js +3 -0
- package/dist/viem/TokenIds.js.map +1 -0
- package/dist/viem/Transaction.d.ts +57 -0
- package/dist/viem/Transaction.d.ts.map +1 -0
- package/dist/viem/Transaction.js +137 -0
- package/dist/viem/Transaction.js.map +1 -0
- package/dist/viem/{transport.d.ts → Transport.d.ts} +3 -3
- package/dist/viem/Transport.d.ts.map +1 -0
- package/dist/viem/{transport.js → Transport.js} +3 -3
- package/dist/viem/Transport.js.map +1 -0
- package/dist/viem/index.d.ts +13 -9
- package/dist/viem/index.d.ts.map +1 -1
- package/dist/viem/index.js +13 -9
- package/dist/viem/index.js.map +1 -1
- package/dist/viem/{types.d.ts → internal/types.d.ts} +3 -3
- package/dist/viem/internal/types.d.ts.map +1 -0
- package/dist/viem/{types.js.map → internal/types.js.map} +1 -1
- package/dist/viem/internal/utils.d.ts.map +1 -0
- package/dist/viem/internal/utils.js.map +1 -0
- package/package.json +87 -101
- package/src/chains.ts +10 -24
- package/src/ox/SignatureEnvelope.test.ts +1252 -0
- package/src/ox/SignatureEnvelope.ts +709 -0
- package/src/ox/Transaction.test.ts +144 -89
- package/src/ox/Transaction.ts +104 -29
- package/src/ox/TransactionEnvelopeAA.test.ts +1533 -0
- package/src/ox/TransactionEnvelopeAA.ts +858 -0
- package/src/ox/TransactionRequest.ts +25 -17
- package/src/ox/index.ts +2 -1
- package/src/prool/Instance.ts +6 -14
- package/src/prool/internal/chain.json +101 -27
- package/src/viem/{abis.ts → Abis.ts} +322 -8
- package/src/viem/{actions → Actions}/amm.test.ts +65 -68
- package/src/viem/{actions → Actions}/amm.ts +72 -60
- package/src/viem/Actions/dex.test.ts +1608 -0
- package/src/viem/Actions/dex.ts +2026 -0
- package/src/viem/{actions → Actions}/fee.test.ts +34 -36
- package/src/viem/{actions → Actions}/fee.ts +18 -17
- package/src/viem/{actions → Actions}/index.ts +1 -0
- package/src/viem/{actions → Actions}/policy.test.ts +2 -2
- package/src/viem/{actions → Actions}/policy.ts +77 -64
- package/src/viem/{actions → Actions}/token.test.ts +419 -64
- package/src/viem/{actions → Actions}/token.ts +751 -145
- package/src/viem/Addresses.ts +9 -0
- package/src/viem/{chain.ts → Chain.ts} +6 -6
- package/src/viem/{client.bench-d.ts → Client.bench-d.ts} +2 -2
- package/src/viem/{client.test.ts → Client.test.ts} +31 -6
- package/src/viem/{client.ts → Client.ts} +1 -1
- package/src/viem/{decorator.bench-d.ts → Decorator.bench-d.ts} +2 -2
- package/src/viem/{decorator.test.ts → Decorator.test.ts} +1 -0
- package/src/viem/{decorator.ts → Decorator.ts} +586 -4
- package/src/viem/{formatters.ts → Formatters.ts} +31 -20
- package/src/viem/Tick.test.ts +281 -0
- package/src/viem/Tick.ts +176 -0
- package/src/viem/TokenIds.ts +2 -0
- package/src/viem/Transaction.ts +303 -0
- package/src/viem/{transport.ts → Transport.ts} +5 -5
- package/src/viem/e2e.test.ts +153 -78
- package/src/viem/index.ts +13 -9
- package/src/viem/{types.ts → internal/types.ts} +3 -3
- package/dist/ox/TransactionEnvelopeFeeToken.d.ts +0 -393
- package/dist/ox/TransactionEnvelopeFeeToken.d.ts.map +0 -1
- package/dist/ox/TransactionEnvelopeFeeToken.js +0 -452
- package/dist/ox/TransactionEnvelopeFeeToken.js.map +0 -1
- package/dist/viem/abis.d.ts.map +0 -1
- package/dist/viem/abis.js.map +0 -1
- package/dist/viem/actions/amm.d.ts.map +0 -1
- package/dist/viem/actions/amm.js.map +0 -1
- package/dist/viem/actions/fee.d.ts.map +0 -1
- package/dist/viem/actions/fee.js.map +0 -1
- package/dist/viem/actions/index.d.ts +0 -5
- package/dist/viem/actions/index.d.ts.map +0 -1
- package/dist/viem/actions/index.js +0 -5
- package/dist/viem/actions/index.js.map +0 -1
- package/dist/viem/actions/policy.d.ts.map +0 -1
- package/dist/viem/actions/policy.js.map +0 -1
- package/dist/viem/actions/token.d.ts.map +0 -1
- package/dist/viem/actions/token.js.map +0 -1
- package/dist/viem/addresses.d.ts +0 -8
- package/dist/viem/addresses.d.ts.map +0 -1
- package/dist/viem/addresses.js +0 -8
- package/dist/viem/addresses.js.map +0 -1
- package/dist/viem/chain.d.ts.map +0 -1
- package/dist/viem/chain.js.map +0 -1
- package/dist/viem/client.d.ts.map +0 -1
- package/dist/viem/client.js.map +0 -1
- package/dist/viem/decorator.d.ts.map +0 -1
- package/dist/viem/decorator.js.map +0 -1
- package/dist/viem/formatters.d.ts.map +0 -1
- package/dist/viem/formatters.js.map +0 -1
- package/dist/viem/transaction.d.ts +0 -54
- package/dist/viem/transaction.d.ts.map +0 -1
- package/dist/viem/transaction.js +0 -108
- package/dist/viem/transaction.js.map +0 -1
- package/dist/viem/transport.d.ts.map +0 -1
- package/dist/viem/transport.js.map +0 -1
- package/dist/viem/types.d.ts.map +0 -1
- package/dist/viem/utils.d.ts.map +0 -1
- package/dist/viem/utils.js.map +0 -1
- package/src/ox/TransactionEnvelopeFeeToken.test.ts +0 -1119
- package/src/ox/TransactionEnvelopeFeeToken.ts +0 -717
- package/src/prool/internal/consensus.toml +0 -32
- package/src/viem/addresses.ts +0 -10
- package/src/viem/transaction.ts +0 -253
- /package/dist/viem/{types.js → internal/types.js} +0 -0
- /package/dist/viem/{utils.d.ts → internal/utils.d.ts} +0 -0
- /package/dist/viem/{utils.js → internal/utils.js} +0 -0
- /package/src/viem/{utils.ts → internal/utils.ts} +0 -0
|
@@ -3,11 +3,11 @@ import * as Signature from 'ox/Signature';
|
|
|
3
3
|
import { encodeFunctionData, parseEventLogs, } from 'viem';
|
|
4
4
|
import { parseAccount } from 'viem/accounts';
|
|
5
5
|
import { multicall, readContract, sendTransaction, sendTransactionSync, watchContractEvent, writeContract, writeContractSync, } from 'viem/actions';
|
|
6
|
-
import * as TokenId from
|
|
7
|
-
import * as TokenRole from
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { defineCall } from
|
|
6
|
+
import * as TokenId from '../../ox/TokenId.js';
|
|
7
|
+
import * as TokenRole from '../../ox/TokenRole.js';
|
|
8
|
+
import * as Abis from '../Abis.js';
|
|
9
|
+
import * as Addresses from '../Addresses.js';
|
|
10
|
+
import { defineCall } from '../internal/utils.js';
|
|
11
11
|
/**
|
|
12
12
|
* Approves a spender to transfer TIP20 tokens on behalf of the caller.
|
|
13
13
|
*
|
|
@@ -35,7 +35,7 @@ import { defineCall } from "../utils.js";
|
|
|
35
35
|
* @returns The transaction hash.
|
|
36
36
|
*/
|
|
37
37
|
export async function approve(client, parameters) {
|
|
38
|
-
const { token =
|
|
38
|
+
const { token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
39
39
|
return approve.inner(writeContract, client, parameters, { ...rest, token });
|
|
40
40
|
}
|
|
41
41
|
(function (approve) {
|
|
@@ -82,10 +82,10 @@ export async function approve(client, parameters) {
|
|
|
82
82
|
* @returns The call.
|
|
83
83
|
*/
|
|
84
84
|
function call(args) {
|
|
85
|
-
const { spender, amount, token =
|
|
85
|
+
const { spender, amount, token = Addresses.defaultFeeToken } = args;
|
|
86
86
|
return defineCall({
|
|
87
87
|
address: TokenId.toAddress(token),
|
|
88
|
-
abi:
|
|
88
|
+
abi: Abis.tip20,
|
|
89
89
|
functionName: 'approve',
|
|
90
90
|
args: [spender, amount],
|
|
91
91
|
});
|
|
@@ -93,7 +93,7 @@ export async function approve(client, parameters) {
|
|
|
93
93
|
approve.call = call;
|
|
94
94
|
function extractEvent(logs) {
|
|
95
95
|
const [log] = parseEventLogs({
|
|
96
|
-
abi:
|
|
96
|
+
abi: Abis.tip20,
|
|
97
97
|
logs,
|
|
98
98
|
eventName: 'Approval',
|
|
99
99
|
});
|
|
@@ -130,7 +130,7 @@ export async function approve(client, parameters) {
|
|
|
130
130
|
* @returns The transaction receipt and event data.
|
|
131
131
|
*/
|
|
132
132
|
export async function approveSync(client, parameters) {
|
|
133
|
-
const { throwOnReceiptRevert = true, token =
|
|
133
|
+
const { throwOnReceiptRevert = true, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
134
134
|
const receipt = await approve.inner(writeContractSync, client, { ...parameters, throwOnReceiptRevert }, {
|
|
135
135
|
...rest,
|
|
136
136
|
token,
|
|
@@ -174,9 +174,10 @@ export async function burnBlocked(client, parameters) {
|
|
|
174
174
|
(function (burnBlocked) {
|
|
175
175
|
/** @internal */
|
|
176
176
|
async function inner(action, client, parameters) {
|
|
177
|
-
const
|
|
177
|
+
const { amount, from, token, ...rest } = parameters;
|
|
178
|
+
const call = burnBlocked.call({ amount, from, token });
|
|
178
179
|
return (await action(client, {
|
|
179
|
-
...
|
|
180
|
+
...rest,
|
|
180
181
|
...call,
|
|
181
182
|
}));
|
|
182
183
|
}
|
|
@@ -218,7 +219,7 @@ export async function burnBlocked(client, parameters) {
|
|
|
218
219
|
const { from, amount, token } = args;
|
|
219
220
|
return defineCall({
|
|
220
221
|
address: TokenId.toAddress(token),
|
|
221
|
-
abi:
|
|
222
|
+
abi: Abis.tip20,
|
|
222
223
|
functionName: 'burnBlocked',
|
|
223
224
|
args: [from, amount],
|
|
224
225
|
});
|
|
@@ -232,7 +233,7 @@ export async function burnBlocked(client, parameters) {
|
|
|
232
233
|
*/
|
|
233
234
|
function extractEvent(logs) {
|
|
234
235
|
const [log] = parseEventLogs({
|
|
235
|
-
abi:
|
|
236
|
+
abi: Abis.tip20,
|
|
236
237
|
logs,
|
|
237
238
|
eventName: 'BurnBlocked',
|
|
238
239
|
});
|
|
@@ -313,9 +314,10 @@ export async function burn(client, parameters) {
|
|
|
313
314
|
(function (burn) {
|
|
314
315
|
/** @internal */
|
|
315
316
|
async function inner(action, client, parameters) {
|
|
316
|
-
const
|
|
317
|
+
const { amount, memo, token, ...rest } = parameters;
|
|
318
|
+
const call = burn.call({ amount, memo, token });
|
|
317
319
|
return (await action(client, {
|
|
318
|
-
...
|
|
320
|
+
...rest,
|
|
319
321
|
...call,
|
|
320
322
|
}));
|
|
321
323
|
}
|
|
@@ -365,7 +367,7 @@ export async function burn(client, parameters) {
|
|
|
365
367
|
};
|
|
366
368
|
return defineCall({
|
|
367
369
|
address: TokenId.toAddress(token),
|
|
368
|
-
abi:
|
|
370
|
+
abi: Abis.tip20,
|
|
369
371
|
...callArgs,
|
|
370
372
|
});
|
|
371
373
|
}
|
|
@@ -378,7 +380,7 @@ export async function burn(client, parameters) {
|
|
|
378
380
|
*/
|
|
379
381
|
function extractEvent(logs) {
|
|
380
382
|
const [log] = parseEventLogs({
|
|
381
|
-
abi:
|
|
383
|
+
abi: Abis.tip20,
|
|
382
384
|
logs,
|
|
383
385
|
eventName: 'Burn',
|
|
384
386
|
});
|
|
@@ -458,9 +460,10 @@ export async function changeTransferPolicy(client, parameters) {
|
|
|
458
460
|
(function (changeTransferPolicy) {
|
|
459
461
|
/** @internal */
|
|
460
462
|
async function inner(action, client, parameters) {
|
|
461
|
-
const
|
|
463
|
+
const { policyId, token, ...rest } = parameters;
|
|
464
|
+
const call = changeTransferPolicy.call({ policyId, token });
|
|
462
465
|
return (await action(client, {
|
|
463
|
-
...
|
|
466
|
+
...rest,
|
|
464
467
|
...call,
|
|
465
468
|
}));
|
|
466
469
|
}
|
|
@@ -501,7 +504,7 @@ export async function changeTransferPolicy(client, parameters) {
|
|
|
501
504
|
const { token, policyId } = args;
|
|
502
505
|
return defineCall({
|
|
503
506
|
address: TokenId.toAddress(token),
|
|
504
|
-
abi:
|
|
507
|
+
abi: Abis.tip20,
|
|
505
508
|
functionName: 'changeTransferPolicyId',
|
|
506
509
|
args: [policyId],
|
|
507
510
|
});
|
|
@@ -515,7 +518,7 @@ export async function changeTransferPolicy(client, parameters) {
|
|
|
515
518
|
*/
|
|
516
519
|
function extractEvent(logs) {
|
|
517
520
|
const [log] = parseEventLogs({
|
|
518
|
-
abi:
|
|
521
|
+
abi: Abis.tip20,
|
|
519
522
|
logs,
|
|
520
523
|
eventName: 'TransferPolicyUpdate',
|
|
521
524
|
});
|
|
@@ -644,11 +647,11 @@ export async function create(client, parameters) {
|
|
|
644
647
|
* @returns The call.
|
|
645
648
|
*/
|
|
646
649
|
function call(args) {
|
|
647
|
-
const { name, symbol, currency, admin } = args;
|
|
650
|
+
const { name, symbol, currency, quoteToken = Addresses.defaultQuoteToken, admin, } = args;
|
|
648
651
|
return defineCall({
|
|
649
|
-
address:
|
|
650
|
-
abi:
|
|
651
|
-
args: [name, symbol, currency, admin],
|
|
652
|
+
address: Addresses.tip20Factory,
|
|
653
|
+
abi: Abis.tip20Factory,
|
|
654
|
+
args: [name, symbol, currency, TokenId.toAddress(quoteToken), admin],
|
|
652
655
|
functionName: 'createToken',
|
|
653
656
|
});
|
|
654
657
|
}
|
|
@@ -661,7 +664,7 @@ export async function create(client, parameters) {
|
|
|
661
664
|
*/
|
|
662
665
|
function extractEvent(logs) {
|
|
663
666
|
const [log] = parseEventLogs({
|
|
664
|
-
abi:
|
|
667
|
+
abi: Abis.tip20Factory,
|
|
665
668
|
logs,
|
|
666
669
|
eventName: 'TokenCreated',
|
|
667
670
|
strict: true,
|
|
@@ -711,6 +714,137 @@ export async function createSync(client, parameters) {
|
|
|
711
714
|
receipt,
|
|
712
715
|
};
|
|
713
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* Finalizes the quote token update for a TIP20 token.
|
|
719
|
+
*
|
|
720
|
+
* @example
|
|
721
|
+
* ```ts
|
|
722
|
+
* import { createClient, http } from 'viem'
|
|
723
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
724
|
+
* import * as actions from 'tempo.ts/viem/actions'
|
|
725
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
726
|
+
*
|
|
727
|
+
* const client = createClient({
|
|
728
|
+
* account: privateKeyToAccount('0x...'),
|
|
729
|
+
* chain: tempo,
|
|
730
|
+
* transport: http(),
|
|
731
|
+
* })
|
|
732
|
+
*
|
|
733
|
+
* const result = await actions.token.finalizeUpdateQuoteToken(client, {
|
|
734
|
+
* token: '0x...',
|
|
735
|
+
* })
|
|
736
|
+
* ```
|
|
737
|
+
*
|
|
738
|
+
* @param client - Client.
|
|
739
|
+
* @param parameters - Parameters.
|
|
740
|
+
* @returns The transaction hash.
|
|
741
|
+
*/
|
|
742
|
+
export async function finalizeUpdateQuoteToken(client, parameters) {
|
|
743
|
+
return finalizeUpdateQuoteToken.inner(writeContract, client, parameters);
|
|
744
|
+
}
|
|
745
|
+
(function (finalizeUpdateQuoteToken) {
|
|
746
|
+
/** @internal */
|
|
747
|
+
async function inner(action, client, parameters) {
|
|
748
|
+
const { token, ...rest } = parameters;
|
|
749
|
+
const call = finalizeUpdateQuoteToken.call({ token });
|
|
750
|
+
return (await action(client, {
|
|
751
|
+
...rest,
|
|
752
|
+
...call,
|
|
753
|
+
}));
|
|
754
|
+
}
|
|
755
|
+
finalizeUpdateQuoteToken.inner = inner;
|
|
756
|
+
/**
|
|
757
|
+
* Defines a call to the `finalizeQuoteTokenUpdate` function.
|
|
758
|
+
*
|
|
759
|
+
* Can be passed as a parameter to:
|
|
760
|
+
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
761
|
+
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
762
|
+
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
763
|
+
*
|
|
764
|
+
* @example
|
|
765
|
+
* ```ts
|
|
766
|
+
* import { createClient, http, walletActions } from 'viem'
|
|
767
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
768
|
+
* import * as actions from 'tempo.ts/viem/actions'
|
|
769
|
+
*
|
|
770
|
+
* const client = createClient({
|
|
771
|
+
* chain: tempo,
|
|
772
|
+
* transport: http(),
|
|
773
|
+
* }).extend(walletActions)
|
|
774
|
+
*
|
|
775
|
+
* const { result } = await client.sendCalls({
|
|
776
|
+
* calls: [
|
|
777
|
+
* actions.token.finalizeUpdateQuoteToken.call({
|
|
778
|
+
* token: '0x20c0...babe',
|
|
779
|
+
* }),
|
|
780
|
+
* ]
|
|
781
|
+
* })
|
|
782
|
+
* ```
|
|
783
|
+
*
|
|
784
|
+
* @param args - Arguments.
|
|
785
|
+
* @returns The call.
|
|
786
|
+
*/
|
|
787
|
+
function call(args) {
|
|
788
|
+
const { token } = args;
|
|
789
|
+
return defineCall({
|
|
790
|
+
address: TokenId.toAddress(token),
|
|
791
|
+
abi: Abis.tip20,
|
|
792
|
+
functionName: 'finalizeQuoteTokenUpdate',
|
|
793
|
+
args: [],
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
finalizeUpdateQuoteToken.call = call;
|
|
797
|
+
/**
|
|
798
|
+
* Extracts the event from the logs.
|
|
799
|
+
*
|
|
800
|
+
* @param logs - Logs.
|
|
801
|
+
* @returns The event.
|
|
802
|
+
*/
|
|
803
|
+
function extractEvent(logs) {
|
|
804
|
+
const [log] = parseEventLogs({
|
|
805
|
+
abi: Abis.tip20,
|
|
806
|
+
logs,
|
|
807
|
+
eventName: 'QuoteTokenUpdateFinalized',
|
|
808
|
+
});
|
|
809
|
+
if (!log)
|
|
810
|
+
throw new Error('`QuoteTokenUpdateFinalized` event not found.');
|
|
811
|
+
return log;
|
|
812
|
+
}
|
|
813
|
+
finalizeUpdateQuoteToken.extractEvent = extractEvent;
|
|
814
|
+
})(finalizeUpdateQuoteToken || (finalizeUpdateQuoteToken = {}));
|
|
815
|
+
/**
|
|
816
|
+
* Finalizes the quote token update for a TIP20 token.
|
|
817
|
+
*
|
|
818
|
+
* @example
|
|
819
|
+
* ```ts
|
|
820
|
+
* import { createClient, http } from 'viem'
|
|
821
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
822
|
+
* import * as actions from 'tempo.ts/viem/actions'
|
|
823
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
824
|
+
*
|
|
825
|
+
* const client = createClient({
|
|
826
|
+
* account: privateKeyToAccount('0x...'),
|
|
827
|
+
* chain: tempo,
|
|
828
|
+
* transport: http(),
|
|
829
|
+
* })
|
|
830
|
+
*
|
|
831
|
+
* const result = await actions.token.finalizeUpdateQuoteTokenSync(client, {
|
|
832
|
+
* token: '0x...',
|
|
833
|
+
* })
|
|
834
|
+
* ```
|
|
835
|
+
*
|
|
836
|
+
* @param client - Client.
|
|
837
|
+
* @param parameters - Parameters.
|
|
838
|
+
* @returns The transaction receipt and event data.
|
|
839
|
+
*/
|
|
840
|
+
export async function finalizeUpdateQuoteTokenSync(client, parameters) {
|
|
841
|
+
const receipt = await finalizeUpdateQuoteToken.inner(writeContractSync, client, parameters);
|
|
842
|
+
const { args } = finalizeUpdateQuoteToken.extractEvent(receipt.logs);
|
|
843
|
+
return {
|
|
844
|
+
...args,
|
|
845
|
+
receipt,
|
|
846
|
+
};
|
|
847
|
+
}
|
|
714
848
|
/**
|
|
715
849
|
* Gets TIP20 token allowance.
|
|
716
850
|
*
|
|
@@ -754,10 +888,10 @@ export async function getAllowance(client, parameters) {
|
|
|
754
888
|
* @returns The call.
|
|
755
889
|
*/
|
|
756
890
|
function call(args) {
|
|
757
|
-
const { account, spender, token =
|
|
891
|
+
const { account, spender, token = Addresses.defaultFeeToken } = args;
|
|
758
892
|
return defineCall({
|
|
759
893
|
address: TokenId.toAddress(token),
|
|
760
|
-
abi:
|
|
894
|
+
abi: Abis.tip20,
|
|
761
895
|
functionName: 'allowance',
|
|
762
896
|
args: [account, spender],
|
|
763
897
|
});
|
|
@@ -807,10 +941,10 @@ export async function getBalance(client, ...parameters) {
|
|
|
807
941
|
* @returns The call.
|
|
808
942
|
*/
|
|
809
943
|
function call(args) {
|
|
810
|
-
const { account, token =
|
|
944
|
+
const { account, token = Addresses.defaultFeeToken } = args;
|
|
811
945
|
return defineCall({
|
|
812
946
|
address: TokenId.toAddress(token),
|
|
813
|
-
abi:
|
|
947
|
+
abi: Abis.tip20,
|
|
814
948
|
functionName: 'balanceOf',
|
|
815
949
|
args: [account],
|
|
816
950
|
});
|
|
@@ -843,9 +977,48 @@ export async function getBalance(client, ...parameters) {
|
|
|
843
977
|
* @returns The token metadata.
|
|
844
978
|
*/
|
|
845
979
|
export async function getMetadata(client, parameters = {}) {
|
|
846
|
-
const { token =
|
|
980
|
+
const { token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
847
981
|
const address = TokenId.toAddress(token);
|
|
848
|
-
const abi =
|
|
982
|
+
const abi = Abis.tip20;
|
|
983
|
+
if (token === TokenId.fromAddress(Addresses.defaultQuoteToken))
|
|
984
|
+
return multicall(client, {
|
|
985
|
+
...rest,
|
|
986
|
+
contracts: [
|
|
987
|
+
{
|
|
988
|
+
address,
|
|
989
|
+
abi,
|
|
990
|
+
functionName: 'currency',
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
address,
|
|
994
|
+
abi,
|
|
995
|
+
functionName: 'decimals',
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
address,
|
|
999
|
+
abi,
|
|
1000
|
+
functionName: 'name',
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
address,
|
|
1004
|
+
abi,
|
|
1005
|
+
functionName: 'symbol',
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
address,
|
|
1009
|
+
abi,
|
|
1010
|
+
functionName: 'totalSupply',
|
|
1011
|
+
},
|
|
1012
|
+
],
|
|
1013
|
+
allowFailure: false,
|
|
1014
|
+
deployless: true,
|
|
1015
|
+
}).then(([currency, decimals, name, symbol, totalSupply]) => ({
|
|
1016
|
+
name,
|
|
1017
|
+
symbol,
|
|
1018
|
+
currency,
|
|
1019
|
+
decimals,
|
|
1020
|
+
totalSupply,
|
|
1021
|
+
}));
|
|
849
1022
|
return multicall(client, {
|
|
850
1023
|
...rest,
|
|
851
1024
|
contracts: [
|
|
@@ -859,6 +1032,11 @@ export async function getMetadata(client, parameters = {}) {
|
|
|
859
1032
|
abi,
|
|
860
1033
|
functionName: 'decimals',
|
|
861
1034
|
},
|
|
1035
|
+
{
|
|
1036
|
+
address,
|
|
1037
|
+
abi,
|
|
1038
|
+
functionName: 'quoteToken',
|
|
1039
|
+
},
|
|
862
1040
|
{
|
|
863
1041
|
address,
|
|
864
1042
|
abi,
|
|
@@ -892,11 +1070,12 @@ export async function getMetadata(client, parameters = {}) {
|
|
|
892
1070
|
],
|
|
893
1071
|
allowFailure: false,
|
|
894
1072
|
deployless: true,
|
|
895
|
-
}).then(([currency, decimals, name, paused, supplyCap, symbol, totalSupply, transferPolicyId,]) => ({
|
|
1073
|
+
}).then(([currency, decimals, quoteToken, name, paused, supplyCap, symbol, totalSupply, transferPolicyId,]) => ({
|
|
896
1074
|
name,
|
|
897
1075
|
symbol,
|
|
898
1076
|
currency,
|
|
899
1077
|
decimals,
|
|
1078
|
+
quoteToken,
|
|
900
1079
|
totalSupply,
|
|
901
1080
|
paused,
|
|
902
1081
|
supplyCap,
|
|
@@ -949,7 +1128,7 @@ export async function hasRole(client, parameters) {
|
|
|
949
1128
|
const { account, role, token } = args;
|
|
950
1129
|
return defineCall({
|
|
951
1130
|
address: TokenId.toAddress(token),
|
|
952
|
-
abi:
|
|
1131
|
+
abi: Abis.tip20,
|
|
953
1132
|
functionName: 'hasRole',
|
|
954
1133
|
args: [account, TokenRole.serialize(role)],
|
|
955
1134
|
});
|
|
@@ -1039,7 +1218,7 @@ export async function grantRoles(client, parameters) {
|
|
|
1039
1218
|
const roleHash = TokenRole.serialize(role);
|
|
1040
1219
|
return defineCall({
|
|
1041
1220
|
address: TokenId.toAddress(token),
|
|
1042
|
-
abi:
|
|
1221
|
+
abi: Abis.tip20,
|
|
1043
1222
|
functionName: 'grantRole',
|
|
1044
1223
|
args: [roleHash, to],
|
|
1045
1224
|
});
|
|
@@ -1053,7 +1232,7 @@ export async function grantRoles(client, parameters) {
|
|
|
1053
1232
|
*/
|
|
1054
1233
|
function extractEvents(logs) {
|
|
1055
1234
|
const events = parseEventLogs({
|
|
1056
|
-
abi:
|
|
1235
|
+
abi: Abis.tip20,
|
|
1057
1236
|
logs,
|
|
1058
1237
|
eventName: 'RoleMembershipUpdated',
|
|
1059
1238
|
});
|
|
@@ -1139,7 +1318,6 @@ export async function mint(client, parameters) {
|
|
|
1139
1318
|
const call = mint.call(parameters);
|
|
1140
1319
|
return (await action(client, {
|
|
1141
1320
|
...parameters,
|
|
1142
|
-
gas: 30000n,
|
|
1143
1321
|
...call,
|
|
1144
1322
|
}));
|
|
1145
1323
|
}
|
|
@@ -1190,7 +1368,7 @@ export async function mint(client, parameters) {
|
|
|
1190
1368
|
};
|
|
1191
1369
|
return defineCall({
|
|
1192
1370
|
address: TokenId.toAddress(token),
|
|
1193
|
-
abi:
|
|
1371
|
+
abi: Abis.tip20,
|
|
1194
1372
|
...callArgs,
|
|
1195
1373
|
});
|
|
1196
1374
|
}
|
|
@@ -1203,7 +1381,7 @@ export async function mint(client, parameters) {
|
|
|
1203
1381
|
*/
|
|
1204
1382
|
function extractEvent(logs) {
|
|
1205
1383
|
const [log] = parseEventLogs({
|
|
1206
|
-
abi:
|
|
1384
|
+
abi: Abis.tip20,
|
|
1207
1385
|
logs,
|
|
1208
1386
|
eventName: 'Mint',
|
|
1209
1387
|
});
|
|
@@ -1283,9 +1461,10 @@ export async function pause(client, parameters) {
|
|
|
1283
1461
|
(function (pause) {
|
|
1284
1462
|
/** @internal */
|
|
1285
1463
|
async function inner(action, client, parameters) {
|
|
1286
|
-
const
|
|
1464
|
+
const { token, ...rest } = parameters;
|
|
1465
|
+
const call = pause.call({ token });
|
|
1287
1466
|
return (await action(client, {
|
|
1288
|
-
...
|
|
1467
|
+
...rest,
|
|
1289
1468
|
...call,
|
|
1290
1469
|
}));
|
|
1291
1470
|
}
|
|
@@ -1325,7 +1504,7 @@ export async function pause(client, parameters) {
|
|
|
1325
1504
|
const { token } = args;
|
|
1326
1505
|
return defineCall({
|
|
1327
1506
|
address: TokenId.toAddress(token),
|
|
1328
|
-
abi:
|
|
1507
|
+
abi: Abis.tip20,
|
|
1329
1508
|
functionName: 'pause',
|
|
1330
1509
|
args: [],
|
|
1331
1510
|
});
|
|
@@ -1339,7 +1518,7 @@ export async function pause(client, parameters) {
|
|
|
1339
1518
|
*/
|
|
1340
1519
|
function extractEvent(logs) {
|
|
1341
1520
|
const [log] = parseEventLogs({
|
|
1342
|
-
abi:
|
|
1521
|
+
abi: Abis.tip20,
|
|
1343
1522
|
logs,
|
|
1344
1523
|
eventName: 'PauseStateUpdate',
|
|
1345
1524
|
});
|
|
@@ -1421,9 +1600,17 @@ export async function permit(client, parameters) {
|
|
|
1421
1600
|
(function (permit) {
|
|
1422
1601
|
/** @internal */
|
|
1423
1602
|
async function inner(action, client, parameters) {
|
|
1424
|
-
const
|
|
1603
|
+
const { owner, spender, value, deadline, signature, token, ...rest } = parameters;
|
|
1604
|
+
const call = permit.call({
|
|
1605
|
+
owner,
|
|
1606
|
+
spender,
|
|
1607
|
+
value,
|
|
1608
|
+
deadline,
|
|
1609
|
+
signature,
|
|
1610
|
+
token,
|
|
1611
|
+
});
|
|
1425
1612
|
return (await action(client, {
|
|
1426
|
-
...
|
|
1613
|
+
...rest,
|
|
1427
1614
|
...call,
|
|
1428
1615
|
}));
|
|
1429
1616
|
}
|
|
@@ -1465,12 +1652,12 @@ export async function permit(client, parameters) {
|
|
|
1465
1652
|
* @returns The call.
|
|
1466
1653
|
*/
|
|
1467
1654
|
function call(args) {
|
|
1468
|
-
const { owner, spender, value, deadline, signature, token =
|
|
1655
|
+
const { owner, spender, value, deadline, signature, token = Addresses.defaultFeeToken, } = args;
|
|
1469
1656
|
const { r, s, yParity } = Signature.from(signature);
|
|
1470
1657
|
const v = Signature.yParityToV(yParity);
|
|
1471
1658
|
return defineCall({
|
|
1472
1659
|
address: TokenId.toAddress(token),
|
|
1473
|
-
abi:
|
|
1660
|
+
abi: Abis.tip20,
|
|
1474
1661
|
functionName: 'permit',
|
|
1475
1662
|
args: [
|
|
1476
1663
|
owner,
|
|
@@ -1492,7 +1679,7 @@ export async function permit(client, parameters) {
|
|
|
1492
1679
|
*/
|
|
1493
1680
|
function extractEvent(logs) {
|
|
1494
1681
|
const [log] = parseEventLogs({
|
|
1495
|
-
abi:
|
|
1682
|
+
abi: Abis.tip20,
|
|
1496
1683
|
logs,
|
|
1497
1684
|
eventName: 'Approval',
|
|
1498
1685
|
});
|
|
@@ -1624,7 +1811,7 @@ export async function renounceRoles(client, parameters) {
|
|
|
1624
1811
|
const roleHash = TokenRole.serialize(role);
|
|
1625
1812
|
return defineCall({
|
|
1626
1813
|
address: TokenId.toAddress(token),
|
|
1627
|
-
abi:
|
|
1814
|
+
abi: Abis.tip20,
|
|
1628
1815
|
functionName: 'renounceRole',
|
|
1629
1816
|
args: [roleHash],
|
|
1630
1817
|
});
|
|
@@ -1638,7 +1825,7 @@ export async function renounceRoles(client, parameters) {
|
|
|
1638
1825
|
*/
|
|
1639
1826
|
function extractEvents(logs) {
|
|
1640
1827
|
const events = parseEventLogs({
|
|
1641
|
-
abi:
|
|
1828
|
+
abi: Abis.tip20,
|
|
1642
1829
|
logs,
|
|
1643
1830
|
eventName: 'RoleMembershipUpdated',
|
|
1644
1831
|
});
|
|
@@ -1770,7 +1957,7 @@ export async function revokeRoles(client, parameters) {
|
|
|
1770
1957
|
const roleHash = TokenRole.serialize(role);
|
|
1771
1958
|
return defineCall({
|
|
1772
1959
|
address: TokenId.toAddress(token),
|
|
1773
|
-
abi:
|
|
1960
|
+
abi: Abis.tip20,
|
|
1774
1961
|
functionName: 'revokeRole',
|
|
1775
1962
|
args: [roleHash, from],
|
|
1776
1963
|
});
|
|
@@ -1784,7 +1971,7 @@ export async function revokeRoles(client, parameters) {
|
|
|
1784
1971
|
*/
|
|
1785
1972
|
function extractEvents(logs) {
|
|
1786
1973
|
const events = parseEventLogs({
|
|
1787
|
-
abi:
|
|
1974
|
+
abi: Abis.tip20,
|
|
1788
1975
|
logs,
|
|
1789
1976
|
eventName: 'RoleMembershipUpdated',
|
|
1790
1977
|
});
|
|
@@ -1866,9 +2053,10 @@ export async function setSupplyCap(client, parameters) {
|
|
|
1866
2053
|
(function (setSupplyCap) {
|
|
1867
2054
|
/** @internal */
|
|
1868
2055
|
async function inner(action, client, parameters) {
|
|
1869
|
-
const
|
|
2056
|
+
const { supplyCap, token, ...rest } = parameters;
|
|
2057
|
+
const call = setSupplyCap.call({ supplyCap, token });
|
|
1870
2058
|
return (await action(client, {
|
|
1871
|
-
...
|
|
2059
|
+
...rest,
|
|
1872
2060
|
...call,
|
|
1873
2061
|
}));
|
|
1874
2062
|
}
|
|
@@ -1909,7 +2097,7 @@ export async function setSupplyCap(client, parameters) {
|
|
|
1909
2097
|
const { token, supplyCap } = args;
|
|
1910
2098
|
return defineCall({
|
|
1911
2099
|
address: TokenId.toAddress(token),
|
|
1912
|
-
abi:
|
|
2100
|
+
abi: Abis.tip20,
|
|
1913
2101
|
functionName: 'setSupplyCap',
|
|
1914
2102
|
args: [supplyCap],
|
|
1915
2103
|
});
|
|
@@ -1923,7 +2111,7 @@ export async function setSupplyCap(client, parameters) {
|
|
|
1923
2111
|
*/
|
|
1924
2112
|
function extractEvent(logs) {
|
|
1925
2113
|
const [log] = parseEventLogs({
|
|
1926
|
-
abi:
|
|
2114
|
+
abi: Abis.tip20,
|
|
1927
2115
|
logs,
|
|
1928
2116
|
eventName: 'SupplyCapUpdate',
|
|
1929
2117
|
});
|
|
@@ -2004,9 +2192,10 @@ export async function setRoleAdmin(client, parameters) {
|
|
|
2004
2192
|
(function (setRoleAdmin) {
|
|
2005
2193
|
/** @internal */
|
|
2006
2194
|
async function inner(action, client, parameters) {
|
|
2007
|
-
const
|
|
2195
|
+
const { adminRole, role, token, ...rest } = parameters;
|
|
2196
|
+
const call = setRoleAdmin.call({ adminRole, role, token });
|
|
2008
2197
|
return (await action(client, {
|
|
2009
|
-
...
|
|
2198
|
+
...rest,
|
|
2010
2199
|
...call,
|
|
2011
2200
|
}));
|
|
2012
2201
|
}
|
|
@@ -2050,7 +2239,7 @@ export async function setRoleAdmin(client, parameters) {
|
|
|
2050
2239
|
const adminRoleHash = TokenRole.serialize(adminRole);
|
|
2051
2240
|
return defineCall({
|
|
2052
2241
|
address: TokenId.toAddress(token),
|
|
2053
|
-
abi:
|
|
2242
|
+
abi: Abis.tip20,
|
|
2054
2243
|
functionName: 'setRoleAdmin',
|
|
2055
2244
|
args: [roleHash, adminRoleHash],
|
|
2056
2245
|
});
|
|
@@ -2064,7 +2253,7 @@ export async function setRoleAdmin(client, parameters) {
|
|
|
2064
2253
|
*/
|
|
2065
2254
|
function extractEvent(logs) {
|
|
2066
2255
|
const [log] = parseEventLogs({
|
|
2067
|
-
abi:
|
|
2256
|
+
abi: Abis.tip20,
|
|
2068
2257
|
logs,
|
|
2069
2258
|
eventName: 'RoleAdminUpdated',
|
|
2070
2259
|
});
|
|
@@ -2145,9 +2334,10 @@ export async function transfer(client, parameters) {
|
|
|
2145
2334
|
(function (transfer) {
|
|
2146
2335
|
/** @internal */
|
|
2147
2336
|
async function inner(action, client, parameters) {
|
|
2148
|
-
const
|
|
2337
|
+
const { amount, from, memo, token, to, ...rest } = parameters;
|
|
2338
|
+
const call = transfer.call({ amount, from, memo, token, to });
|
|
2149
2339
|
return (await action(client, {
|
|
2150
|
-
...
|
|
2340
|
+
...rest,
|
|
2151
2341
|
...call,
|
|
2152
2342
|
}));
|
|
2153
2343
|
}
|
|
@@ -2186,7 +2376,7 @@ export async function transfer(client, parameters) {
|
|
|
2186
2376
|
* @returns The call.
|
|
2187
2377
|
*/
|
|
2188
2378
|
function call(args) {
|
|
2189
|
-
const { amount, from, memo, token =
|
|
2379
|
+
const { amount, from, memo, token = Addresses.defaultFeeToken, to } = args;
|
|
2190
2380
|
const callArgs = (() => {
|
|
2191
2381
|
if (memo && from)
|
|
2192
2382
|
return {
|
|
@@ -2210,7 +2400,7 @@ export async function transfer(client, parameters) {
|
|
|
2210
2400
|
})();
|
|
2211
2401
|
return defineCall({
|
|
2212
2402
|
address: TokenId.toAddress(token),
|
|
2213
|
-
abi:
|
|
2403
|
+
abi: Abis.tip20,
|
|
2214
2404
|
...callArgs,
|
|
2215
2405
|
});
|
|
2216
2406
|
}
|
|
@@ -2223,7 +2413,7 @@ export async function transfer(client, parameters) {
|
|
|
2223
2413
|
*/
|
|
2224
2414
|
function extractEvent(logs) {
|
|
2225
2415
|
const [log] = parseEventLogs({
|
|
2226
|
-
abi:
|
|
2416
|
+
abi: Abis.tip20,
|
|
2227
2417
|
logs,
|
|
2228
2418
|
eventName: 'Transfer',
|
|
2229
2419
|
});
|
|
@@ -2302,9 +2492,10 @@ export async function unpause(client, parameters) {
|
|
|
2302
2492
|
(function (unpause) {
|
|
2303
2493
|
/** @internal */
|
|
2304
2494
|
async function inner(action, client, parameters) {
|
|
2305
|
-
const
|
|
2495
|
+
const { token, ...rest } = parameters;
|
|
2496
|
+
const call = unpause.call({ token });
|
|
2306
2497
|
return (await action(client, {
|
|
2307
|
-
...
|
|
2498
|
+
...rest,
|
|
2308
2499
|
...call,
|
|
2309
2500
|
}));
|
|
2310
2501
|
}
|
|
@@ -2344,7 +2535,7 @@ export async function unpause(client, parameters) {
|
|
|
2344
2535
|
const { token } = args;
|
|
2345
2536
|
return defineCall({
|
|
2346
2537
|
address: TokenId.toAddress(token),
|
|
2347
|
-
abi:
|
|
2538
|
+
abi: Abis.tip20,
|
|
2348
2539
|
functionName: 'unpause',
|
|
2349
2540
|
args: [],
|
|
2350
2541
|
});
|
|
@@ -2358,7 +2549,7 @@ export async function unpause(client, parameters) {
|
|
|
2358
2549
|
*/
|
|
2359
2550
|
function extractEvent(logs) {
|
|
2360
2551
|
const [log] = parseEventLogs({
|
|
2361
|
-
abi:
|
|
2552
|
+
abi: Abis.tip20,
|
|
2362
2553
|
logs,
|
|
2363
2554
|
eventName: 'PauseStateUpdate',
|
|
2364
2555
|
});
|
|
@@ -2405,6 +2596,140 @@ export async function unpauseSync(client, parameters) {
|
|
|
2405
2596
|
receipt,
|
|
2406
2597
|
};
|
|
2407
2598
|
}
|
|
2599
|
+
/**
|
|
2600
|
+
* Updates the quote token for a TIP20 token.
|
|
2601
|
+
*
|
|
2602
|
+
* @example
|
|
2603
|
+
* ```ts
|
|
2604
|
+
* import { createClient, http } from 'viem'
|
|
2605
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
2606
|
+
* import * as actions from 'tempo.ts/viem/actions'
|
|
2607
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
2608
|
+
*
|
|
2609
|
+
* const client = createClient({
|
|
2610
|
+
* account: privateKeyToAccount('0x...'),
|
|
2611
|
+
* chain: tempo,
|
|
2612
|
+
* transport: http(),
|
|
2613
|
+
* })
|
|
2614
|
+
*
|
|
2615
|
+
* const result = await actions.token.updateQuoteToken(client, {
|
|
2616
|
+
* token: '0x...',
|
|
2617
|
+
* quoteToken: '0x...',
|
|
2618
|
+
* })
|
|
2619
|
+
* ```
|
|
2620
|
+
*
|
|
2621
|
+
* @param client - Client.
|
|
2622
|
+
* @param parameters - Parameters.
|
|
2623
|
+
* @returns The transaction hash.
|
|
2624
|
+
*/
|
|
2625
|
+
export async function updateQuoteToken(client, parameters) {
|
|
2626
|
+
return updateQuoteToken.inner(writeContract, client, parameters);
|
|
2627
|
+
}
|
|
2628
|
+
(function (updateQuoteToken) {
|
|
2629
|
+
/** @internal */
|
|
2630
|
+
async function inner(action, client, parameters) {
|
|
2631
|
+
const { quoteToken, token, ...rest } = parameters;
|
|
2632
|
+
const call = updateQuoteToken.call({ quoteToken, token });
|
|
2633
|
+
return (await action(client, {
|
|
2634
|
+
...rest,
|
|
2635
|
+
...call,
|
|
2636
|
+
}));
|
|
2637
|
+
}
|
|
2638
|
+
updateQuoteToken.inner = inner;
|
|
2639
|
+
/**
|
|
2640
|
+
* Defines a call to the `updateQuoteToken` function.
|
|
2641
|
+
*
|
|
2642
|
+
* Can be passed as a parameter to:
|
|
2643
|
+
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
2644
|
+
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
2645
|
+
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
2646
|
+
*
|
|
2647
|
+
* @example
|
|
2648
|
+
* ```ts
|
|
2649
|
+
* import { createClient, http, walletActions } from 'viem'
|
|
2650
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
2651
|
+
* import * as actions from 'tempo.ts/viem/actions'
|
|
2652
|
+
*
|
|
2653
|
+
* const client = createClient({
|
|
2654
|
+
* chain: tempo,
|
|
2655
|
+
* transport: http(),
|
|
2656
|
+
* }).extend(walletActions)
|
|
2657
|
+
*
|
|
2658
|
+
* const { result } = await client.sendCalls({
|
|
2659
|
+
* calls: [
|
|
2660
|
+
* actions.token.updateQuoteToken.call({
|
|
2661
|
+
* token: '0x20c0...babe',
|
|
2662
|
+
* quoteToken: '0x20c0...cafe',
|
|
2663
|
+
* }),
|
|
2664
|
+
* ]
|
|
2665
|
+
* })
|
|
2666
|
+
* ```
|
|
2667
|
+
*
|
|
2668
|
+
* @param args - Arguments.
|
|
2669
|
+
* @returns The call.
|
|
2670
|
+
*/
|
|
2671
|
+
function call(args) {
|
|
2672
|
+
const { token, quoteToken } = args;
|
|
2673
|
+
return defineCall({
|
|
2674
|
+
address: TokenId.toAddress(token),
|
|
2675
|
+
abi: Abis.tip20,
|
|
2676
|
+
functionName: 'updateQuoteToken',
|
|
2677
|
+
args: [TokenId.toAddress(quoteToken)],
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
updateQuoteToken.call = call;
|
|
2681
|
+
/**
|
|
2682
|
+
* Extracts the event from the logs.
|
|
2683
|
+
*
|
|
2684
|
+
* @param logs - Logs.
|
|
2685
|
+
* @returns The event.
|
|
2686
|
+
*/
|
|
2687
|
+
function extractEvent(logs) {
|
|
2688
|
+
const [log] = parseEventLogs({
|
|
2689
|
+
abi: Abis.tip20,
|
|
2690
|
+
logs,
|
|
2691
|
+
eventName: 'UpdateQuoteToken',
|
|
2692
|
+
});
|
|
2693
|
+
if (!log)
|
|
2694
|
+
throw new Error('`UpdateQuoteToken` event not found.');
|
|
2695
|
+
return log;
|
|
2696
|
+
}
|
|
2697
|
+
updateQuoteToken.extractEvent = extractEvent;
|
|
2698
|
+
})(updateQuoteToken || (updateQuoteToken = {}));
|
|
2699
|
+
/**
|
|
2700
|
+
* Updates the quote token for a TIP20 token.
|
|
2701
|
+
*
|
|
2702
|
+
* @example
|
|
2703
|
+
* ```ts
|
|
2704
|
+
* import { createClient, http } from 'viem'
|
|
2705
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
2706
|
+
* import * as actions from 'tempo.ts/viem/actions'
|
|
2707
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
2708
|
+
*
|
|
2709
|
+
* const client = createClient({
|
|
2710
|
+
* account: privateKeyToAccount('0x...'),
|
|
2711
|
+
* chain: tempo,
|
|
2712
|
+
* transport: http(),
|
|
2713
|
+
* })
|
|
2714
|
+
*
|
|
2715
|
+
* const result = await actions.token.updateQuoteTokenSync(client, {
|
|
2716
|
+
* token: '0x...',
|
|
2717
|
+
* quoteToken: '0x...',
|
|
2718
|
+
* })
|
|
2719
|
+
* ```
|
|
2720
|
+
*
|
|
2721
|
+
* @param client - Client.
|
|
2722
|
+
* @param parameters - Parameters.
|
|
2723
|
+
* @returns The transaction receipt and event data.
|
|
2724
|
+
*/
|
|
2725
|
+
export async function updateQuoteTokenSync(client, parameters) {
|
|
2726
|
+
const receipt = await updateQuoteToken.inner(writeContractSync, client, parameters);
|
|
2727
|
+
const { args } = updateQuoteToken.extractEvent(receipt.logs);
|
|
2728
|
+
return {
|
|
2729
|
+
...args,
|
|
2730
|
+
receipt,
|
|
2731
|
+
};
|
|
2732
|
+
}
|
|
2408
2733
|
/**
|
|
2409
2734
|
* Watches for TIP20 token approval events.
|
|
2410
2735
|
*
|
|
@@ -2431,11 +2756,11 @@ export async function unpauseSync(client, parameters) {
|
|
|
2431
2756
|
* @returns A function to unsubscribe from the event.
|
|
2432
2757
|
*/
|
|
2433
2758
|
export function watchApprove(client, parameters) {
|
|
2434
|
-
const { onApproval, token =
|
|
2759
|
+
const { onApproval, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
2435
2760
|
return watchContractEvent(client, {
|
|
2436
2761
|
...rest,
|
|
2437
2762
|
address: TokenId.toAddress(token),
|
|
2438
|
-
abi:
|
|
2763
|
+
abi: Abis.tip20,
|
|
2439
2764
|
eventName: 'Approval',
|
|
2440
2765
|
onLogs: (logs) => {
|
|
2441
2766
|
for (const log of logs)
|
|
@@ -2470,11 +2795,11 @@ export function watchApprove(client, parameters) {
|
|
|
2470
2795
|
* @returns A function to unsubscribe from the event.
|
|
2471
2796
|
*/
|
|
2472
2797
|
export function watchBurn(client, parameters) {
|
|
2473
|
-
const { onBurn, token =
|
|
2798
|
+
const { onBurn, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
2474
2799
|
return watchContractEvent(client, {
|
|
2475
2800
|
...rest,
|
|
2476
2801
|
address: TokenId.toAddress(token),
|
|
2477
|
-
abi:
|
|
2802
|
+
abi: Abis.tip20,
|
|
2478
2803
|
eventName: 'Burn',
|
|
2479
2804
|
onLogs: (logs) => {
|
|
2480
2805
|
for (const log of logs)
|
|
@@ -2512,8 +2837,8 @@ export function watchCreate(client, parameters) {
|
|
|
2512
2837
|
const { onTokenCreated, ...rest } = parameters;
|
|
2513
2838
|
return watchContractEvent(client, {
|
|
2514
2839
|
...rest,
|
|
2515
|
-
address:
|
|
2516
|
-
abi:
|
|
2840
|
+
address: Addresses.tip20Factory,
|
|
2841
|
+
abi: Abis.tip20Factory,
|
|
2517
2842
|
eventName: 'TokenCreated',
|
|
2518
2843
|
onLogs: (logs) => {
|
|
2519
2844
|
for (const log of logs)
|
|
@@ -2548,11 +2873,11 @@ export function watchCreate(client, parameters) {
|
|
|
2548
2873
|
* @returns A function to unsubscribe from the event.
|
|
2549
2874
|
*/
|
|
2550
2875
|
export function watchMint(client, parameters) {
|
|
2551
|
-
const { onMint, token =
|
|
2876
|
+
const { onMint, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
2552
2877
|
return watchContractEvent(client, {
|
|
2553
2878
|
...rest,
|
|
2554
2879
|
address: TokenId.toAddress(token),
|
|
2555
|
-
abi:
|
|
2880
|
+
abi: Abis.tip20,
|
|
2556
2881
|
eventName: 'Mint',
|
|
2557
2882
|
onLogs: (logs) => {
|
|
2558
2883
|
for (const log of logs)
|
|
@@ -2587,11 +2912,11 @@ export function watchMint(client, parameters) {
|
|
|
2587
2912
|
* @returns A function to unsubscribe from the event.
|
|
2588
2913
|
*/
|
|
2589
2914
|
export function watchAdminRole(client, parameters) {
|
|
2590
|
-
const { onRoleAdminUpdated, token =
|
|
2915
|
+
const { onRoleAdminUpdated, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
2591
2916
|
return watchContractEvent(client, {
|
|
2592
2917
|
...rest,
|
|
2593
2918
|
address: TokenId.toAddress(token),
|
|
2594
|
-
abi:
|
|
2919
|
+
abi: Abis.tip20,
|
|
2595
2920
|
eventName: 'RoleAdminUpdated',
|
|
2596
2921
|
onLogs: (logs) => {
|
|
2597
2922
|
for (const log of logs)
|
|
@@ -2626,11 +2951,11 @@ export function watchAdminRole(client, parameters) {
|
|
|
2626
2951
|
* @returns A function to unsubscribe from the event.
|
|
2627
2952
|
*/
|
|
2628
2953
|
export function watchRole(client, parameters) {
|
|
2629
|
-
const { onRoleUpdated, token =
|
|
2954
|
+
const { onRoleUpdated, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
2630
2955
|
return watchContractEvent(client, {
|
|
2631
2956
|
...rest,
|
|
2632
2957
|
address: TokenId.toAddress(token),
|
|
2633
|
-
abi:
|
|
2958
|
+
abi: Abis.tip20,
|
|
2634
2959
|
eventName: 'RoleMembershipUpdated',
|
|
2635
2960
|
onLogs: (logs) => {
|
|
2636
2961
|
for (const log of logs) {
|
|
@@ -2668,11 +2993,11 @@ export function watchRole(client, parameters) {
|
|
|
2668
2993
|
* @returns A function to unsubscribe from the event.
|
|
2669
2994
|
*/
|
|
2670
2995
|
export function watchTransfer(client, parameters) {
|
|
2671
|
-
const { onTransfer, token =
|
|
2996
|
+
const { onTransfer, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
2672
2997
|
return watchContractEvent(client, {
|
|
2673
2998
|
...rest,
|
|
2674
2999
|
address: TokenId.toAddress(token),
|
|
2675
|
-
abi:
|
|
3000
|
+
abi: Abis.tip20,
|
|
2676
3001
|
eventName: 'Transfer',
|
|
2677
3002
|
onLogs: (logs) => {
|
|
2678
3003
|
for (const log of logs)
|
|
@@ -2681,4 +3006,53 @@ export function watchTransfer(client, parameters) {
|
|
|
2681
3006
|
strict: true,
|
|
2682
3007
|
});
|
|
2683
3008
|
}
|
|
3009
|
+
/**
|
|
3010
|
+
* Watches for TIP20 token quote token update events.
|
|
3011
|
+
*
|
|
3012
|
+
* @example
|
|
3013
|
+
* ```ts
|
|
3014
|
+
* import { createClient, http } from 'viem'
|
|
3015
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
3016
|
+
* import * as actions from 'tempo.ts/viem/actions'
|
|
3017
|
+
*
|
|
3018
|
+
* const client = createClient({
|
|
3019
|
+
* chain: tempo,
|
|
3020
|
+
* transport: http(),
|
|
3021
|
+
* })
|
|
3022
|
+
*
|
|
3023
|
+
* const unwatch = actions.token.watchUpdateQuoteToken(client, {
|
|
3024
|
+
* onUpdateQuoteToken: (args, log) => {
|
|
3025
|
+
* if (args.finalized)
|
|
3026
|
+
* console.log('quote token update finalized:', args.newQuoteToken)
|
|
3027
|
+
* else
|
|
3028
|
+
* console.log('quote token update proposed:', args.newQuoteToken)
|
|
3029
|
+
* },
|
|
3030
|
+
* })
|
|
3031
|
+
* ```
|
|
3032
|
+
*
|
|
3033
|
+
* @param client - Client.
|
|
3034
|
+
* @param parameters - Parameters.
|
|
3035
|
+
* @returns A function to unsubscribe from the event.
|
|
3036
|
+
*/
|
|
3037
|
+
export function watchUpdateQuoteToken(client, parameters) {
|
|
3038
|
+
const { onUpdateQuoteToken, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
3039
|
+
const address = TokenId.toAddress(token);
|
|
3040
|
+
return watchContractEvent(client, {
|
|
3041
|
+
...rest,
|
|
3042
|
+
address,
|
|
3043
|
+
abi: Abis.tip20,
|
|
3044
|
+
onLogs: (logs) => {
|
|
3045
|
+
for (const log of logs) {
|
|
3046
|
+
if (log.eventName !== 'UpdateQuoteToken' &&
|
|
3047
|
+
log.eventName !== 'QuoteTokenUpdateFinalized')
|
|
3048
|
+
continue;
|
|
3049
|
+
onUpdateQuoteToken({
|
|
3050
|
+
...log.args,
|
|
3051
|
+
finalized: log.eventName === 'QuoteTokenUpdateFinalized',
|
|
3052
|
+
}, log);
|
|
3053
|
+
}
|
|
3054
|
+
},
|
|
3055
|
+
strict: true,
|
|
3056
|
+
});
|
|
3057
|
+
}
|
|
2684
3058
|
//# sourceMappingURL=token.js.map
|