tempo.ts 0.0.6 → 0.1.0
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 +3250 -700
- package/dist/viem/Actions/token.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/token.js +419 -83
- 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 +403 -64
- package/src/viem/{actions → Actions}/token.ts +672 -133
- 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,9 @@ 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;
|
|
849
983
|
return multicall(client, {
|
|
850
984
|
...rest,
|
|
851
985
|
contracts: [
|
|
@@ -859,6 +993,11 @@ export async function getMetadata(client, parameters = {}) {
|
|
|
859
993
|
abi,
|
|
860
994
|
functionName: 'decimals',
|
|
861
995
|
},
|
|
996
|
+
{
|
|
997
|
+
address,
|
|
998
|
+
abi,
|
|
999
|
+
functionName: 'quoteToken',
|
|
1000
|
+
},
|
|
862
1001
|
{
|
|
863
1002
|
address,
|
|
864
1003
|
abi,
|
|
@@ -892,11 +1031,12 @@ export async function getMetadata(client, parameters = {}) {
|
|
|
892
1031
|
],
|
|
893
1032
|
allowFailure: false,
|
|
894
1033
|
deployless: true,
|
|
895
|
-
}).then(([currency, decimals, name, paused, supplyCap, symbol, totalSupply, transferPolicyId,]) => ({
|
|
1034
|
+
}).then(([currency, decimals, quoteToken, name, paused, supplyCap, symbol, totalSupply, transferPolicyId,]) => ({
|
|
896
1035
|
name,
|
|
897
1036
|
symbol,
|
|
898
1037
|
currency,
|
|
899
1038
|
decimals,
|
|
1039
|
+
quoteToken,
|
|
900
1040
|
totalSupply,
|
|
901
1041
|
paused,
|
|
902
1042
|
supplyCap,
|
|
@@ -949,7 +1089,7 @@ export async function hasRole(client, parameters) {
|
|
|
949
1089
|
const { account, role, token } = args;
|
|
950
1090
|
return defineCall({
|
|
951
1091
|
address: TokenId.toAddress(token),
|
|
952
|
-
abi:
|
|
1092
|
+
abi: Abis.tip20,
|
|
953
1093
|
functionName: 'hasRole',
|
|
954
1094
|
args: [account, TokenRole.serialize(role)],
|
|
955
1095
|
});
|
|
@@ -1039,7 +1179,7 @@ export async function grantRoles(client, parameters) {
|
|
|
1039
1179
|
const roleHash = TokenRole.serialize(role);
|
|
1040
1180
|
return defineCall({
|
|
1041
1181
|
address: TokenId.toAddress(token),
|
|
1042
|
-
abi:
|
|
1182
|
+
abi: Abis.tip20,
|
|
1043
1183
|
functionName: 'grantRole',
|
|
1044
1184
|
args: [roleHash, to],
|
|
1045
1185
|
});
|
|
@@ -1053,7 +1193,7 @@ export async function grantRoles(client, parameters) {
|
|
|
1053
1193
|
*/
|
|
1054
1194
|
function extractEvents(logs) {
|
|
1055
1195
|
const events = parseEventLogs({
|
|
1056
|
-
abi:
|
|
1196
|
+
abi: Abis.tip20,
|
|
1057
1197
|
logs,
|
|
1058
1198
|
eventName: 'RoleMembershipUpdated',
|
|
1059
1199
|
});
|
|
@@ -1190,7 +1330,7 @@ export async function mint(client, parameters) {
|
|
|
1190
1330
|
};
|
|
1191
1331
|
return defineCall({
|
|
1192
1332
|
address: TokenId.toAddress(token),
|
|
1193
|
-
abi:
|
|
1333
|
+
abi: Abis.tip20,
|
|
1194
1334
|
...callArgs,
|
|
1195
1335
|
});
|
|
1196
1336
|
}
|
|
@@ -1203,7 +1343,7 @@ export async function mint(client, parameters) {
|
|
|
1203
1343
|
*/
|
|
1204
1344
|
function extractEvent(logs) {
|
|
1205
1345
|
const [log] = parseEventLogs({
|
|
1206
|
-
abi:
|
|
1346
|
+
abi: Abis.tip20,
|
|
1207
1347
|
logs,
|
|
1208
1348
|
eventName: 'Mint',
|
|
1209
1349
|
});
|
|
@@ -1283,9 +1423,10 @@ export async function pause(client, parameters) {
|
|
|
1283
1423
|
(function (pause) {
|
|
1284
1424
|
/** @internal */
|
|
1285
1425
|
async function inner(action, client, parameters) {
|
|
1286
|
-
const
|
|
1426
|
+
const { token, ...rest } = parameters;
|
|
1427
|
+
const call = pause.call({ token });
|
|
1287
1428
|
return (await action(client, {
|
|
1288
|
-
...
|
|
1429
|
+
...rest,
|
|
1289
1430
|
...call,
|
|
1290
1431
|
}));
|
|
1291
1432
|
}
|
|
@@ -1325,7 +1466,7 @@ export async function pause(client, parameters) {
|
|
|
1325
1466
|
const { token } = args;
|
|
1326
1467
|
return defineCall({
|
|
1327
1468
|
address: TokenId.toAddress(token),
|
|
1328
|
-
abi:
|
|
1469
|
+
abi: Abis.tip20,
|
|
1329
1470
|
functionName: 'pause',
|
|
1330
1471
|
args: [],
|
|
1331
1472
|
});
|
|
@@ -1339,7 +1480,7 @@ export async function pause(client, parameters) {
|
|
|
1339
1480
|
*/
|
|
1340
1481
|
function extractEvent(logs) {
|
|
1341
1482
|
const [log] = parseEventLogs({
|
|
1342
|
-
abi:
|
|
1483
|
+
abi: Abis.tip20,
|
|
1343
1484
|
logs,
|
|
1344
1485
|
eventName: 'PauseStateUpdate',
|
|
1345
1486
|
});
|
|
@@ -1421,9 +1562,17 @@ export async function permit(client, parameters) {
|
|
|
1421
1562
|
(function (permit) {
|
|
1422
1563
|
/** @internal */
|
|
1423
1564
|
async function inner(action, client, parameters) {
|
|
1424
|
-
const
|
|
1565
|
+
const { owner, spender, value, deadline, signature, token, ...rest } = parameters;
|
|
1566
|
+
const call = permit.call({
|
|
1567
|
+
owner,
|
|
1568
|
+
spender,
|
|
1569
|
+
value,
|
|
1570
|
+
deadline,
|
|
1571
|
+
signature,
|
|
1572
|
+
token,
|
|
1573
|
+
});
|
|
1425
1574
|
return (await action(client, {
|
|
1426
|
-
...
|
|
1575
|
+
...rest,
|
|
1427
1576
|
...call,
|
|
1428
1577
|
}));
|
|
1429
1578
|
}
|
|
@@ -1465,12 +1614,12 @@ export async function permit(client, parameters) {
|
|
|
1465
1614
|
* @returns The call.
|
|
1466
1615
|
*/
|
|
1467
1616
|
function call(args) {
|
|
1468
|
-
const { owner, spender, value, deadline, signature, token =
|
|
1617
|
+
const { owner, spender, value, deadline, signature, token = Addresses.defaultFeeToken, } = args;
|
|
1469
1618
|
const { r, s, yParity } = Signature.from(signature);
|
|
1470
1619
|
const v = Signature.yParityToV(yParity);
|
|
1471
1620
|
return defineCall({
|
|
1472
1621
|
address: TokenId.toAddress(token),
|
|
1473
|
-
abi:
|
|
1622
|
+
abi: Abis.tip20,
|
|
1474
1623
|
functionName: 'permit',
|
|
1475
1624
|
args: [
|
|
1476
1625
|
owner,
|
|
@@ -1492,7 +1641,7 @@ export async function permit(client, parameters) {
|
|
|
1492
1641
|
*/
|
|
1493
1642
|
function extractEvent(logs) {
|
|
1494
1643
|
const [log] = parseEventLogs({
|
|
1495
|
-
abi:
|
|
1644
|
+
abi: Abis.tip20,
|
|
1496
1645
|
logs,
|
|
1497
1646
|
eventName: 'Approval',
|
|
1498
1647
|
});
|
|
@@ -1624,7 +1773,7 @@ export async function renounceRoles(client, parameters) {
|
|
|
1624
1773
|
const roleHash = TokenRole.serialize(role);
|
|
1625
1774
|
return defineCall({
|
|
1626
1775
|
address: TokenId.toAddress(token),
|
|
1627
|
-
abi:
|
|
1776
|
+
abi: Abis.tip20,
|
|
1628
1777
|
functionName: 'renounceRole',
|
|
1629
1778
|
args: [roleHash],
|
|
1630
1779
|
});
|
|
@@ -1638,7 +1787,7 @@ export async function renounceRoles(client, parameters) {
|
|
|
1638
1787
|
*/
|
|
1639
1788
|
function extractEvents(logs) {
|
|
1640
1789
|
const events = parseEventLogs({
|
|
1641
|
-
abi:
|
|
1790
|
+
abi: Abis.tip20,
|
|
1642
1791
|
logs,
|
|
1643
1792
|
eventName: 'RoleMembershipUpdated',
|
|
1644
1793
|
});
|
|
@@ -1770,7 +1919,7 @@ export async function revokeRoles(client, parameters) {
|
|
|
1770
1919
|
const roleHash = TokenRole.serialize(role);
|
|
1771
1920
|
return defineCall({
|
|
1772
1921
|
address: TokenId.toAddress(token),
|
|
1773
|
-
abi:
|
|
1922
|
+
abi: Abis.tip20,
|
|
1774
1923
|
functionName: 'revokeRole',
|
|
1775
1924
|
args: [roleHash, from],
|
|
1776
1925
|
});
|
|
@@ -1784,7 +1933,7 @@ export async function revokeRoles(client, parameters) {
|
|
|
1784
1933
|
*/
|
|
1785
1934
|
function extractEvents(logs) {
|
|
1786
1935
|
const events = parseEventLogs({
|
|
1787
|
-
abi:
|
|
1936
|
+
abi: Abis.tip20,
|
|
1788
1937
|
logs,
|
|
1789
1938
|
eventName: 'RoleMembershipUpdated',
|
|
1790
1939
|
});
|
|
@@ -1866,9 +2015,10 @@ export async function setSupplyCap(client, parameters) {
|
|
|
1866
2015
|
(function (setSupplyCap) {
|
|
1867
2016
|
/** @internal */
|
|
1868
2017
|
async function inner(action, client, parameters) {
|
|
1869
|
-
const
|
|
2018
|
+
const { supplyCap, token, ...rest } = parameters;
|
|
2019
|
+
const call = setSupplyCap.call({ supplyCap, token });
|
|
1870
2020
|
return (await action(client, {
|
|
1871
|
-
...
|
|
2021
|
+
...rest,
|
|
1872
2022
|
...call,
|
|
1873
2023
|
}));
|
|
1874
2024
|
}
|
|
@@ -1909,7 +2059,7 @@ export async function setSupplyCap(client, parameters) {
|
|
|
1909
2059
|
const { token, supplyCap } = args;
|
|
1910
2060
|
return defineCall({
|
|
1911
2061
|
address: TokenId.toAddress(token),
|
|
1912
|
-
abi:
|
|
2062
|
+
abi: Abis.tip20,
|
|
1913
2063
|
functionName: 'setSupplyCap',
|
|
1914
2064
|
args: [supplyCap],
|
|
1915
2065
|
});
|
|
@@ -1923,7 +2073,7 @@ export async function setSupplyCap(client, parameters) {
|
|
|
1923
2073
|
*/
|
|
1924
2074
|
function extractEvent(logs) {
|
|
1925
2075
|
const [log] = parseEventLogs({
|
|
1926
|
-
abi:
|
|
2076
|
+
abi: Abis.tip20,
|
|
1927
2077
|
logs,
|
|
1928
2078
|
eventName: 'SupplyCapUpdate',
|
|
1929
2079
|
});
|
|
@@ -2004,9 +2154,10 @@ export async function setRoleAdmin(client, parameters) {
|
|
|
2004
2154
|
(function (setRoleAdmin) {
|
|
2005
2155
|
/** @internal */
|
|
2006
2156
|
async function inner(action, client, parameters) {
|
|
2007
|
-
const
|
|
2157
|
+
const { adminRole, role, token, ...rest } = parameters;
|
|
2158
|
+
const call = setRoleAdmin.call({ adminRole, role, token });
|
|
2008
2159
|
return (await action(client, {
|
|
2009
|
-
...
|
|
2160
|
+
...rest,
|
|
2010
2161
|
...call,
|
|
2011
2162
|
}));
|
|
2012
2163
|
}
|
|
@@ -2050,7 +2201,7 @@ export async function setRoleAdmin(client, parameters) {
|
|
|
2050
2201
|
const adminRoleHash = TokenRole.serialize(adminRole);
|
|
2051
2202
|
return defineCall({
|
|
2052
2203
|
address: TokenId.toAddress(token),
|
|
2053
|
-
abi:
|
|
2204
|
+
abi: Abis.tip20,
|
|
2054
2205
|
functionName: 'setRoleAdmin',
|
|
2055
2206
|
args: [roleHash, adminRoleHash],
|
|
2056
2207
|
});
|
|
@@ -2064,7 +2215,7 @@ export async function setRoleAdmin(client, parameters) {
|
|
|
2064
2215
|
*/
|
|
2065
2216
|
function extractEvent(logs) {
|
|
2066
2217
|
const [log] = parseEventLogs({
|
|
2067
|
-
abi:
|
|
2218
|
+
abi: Abis.tip20,
|
|
2068
2219
|
logs,
|
|
2069
2220
|
eventName: 'RoleAdminUpdated',
|
|
2070
2221
|
});
|
|
@@ -2145,9 +2296,10 @@ export async function transfer(client, parameters) {
|
|
|
2145
2296
|
(function (transfer) {
|
|
2146
2297
|
/** @internal */
|
|
2147
2298
|
async function inner(action, client, parameters) {
|
|
2148
|
-
const
|
|
2299
|
+
const { amount, from, memo, token, to, ...rest } = parameters;
|
|
2300
|
+
const call = transfer.call({ amount, from, memo, token, to });
|
|
2149
2301
|
return (await action(client, {
|
|
2150
|
-
...
|
|
2302
|
+
...rest,
|
|
2151
2303
|
...call,
|
|
2152
2304
|
}));
|
|
2153
2305
|
}
|
|
@@ -2186,7 +2338,7 @@ export async function transfer(client, parameters) {
|
|
|
2186
2338
|
* @returns The call.
|
|
2187
2339
|
*/
|
|
2188
2340
|
function call(args) {
|
|
2189
|
-
const { amount, from, memo, token =
|
|
2341
|
+
const { amount, from, memo, token = Addresses.defaultFeeToken, to } = args;
|
|
2190
2342
|
const callArgs = (() => {
|
|
2191
2343
|
if (memo && from)
|
|
2192
2344
|
return {
|
|
@@ -2210,7 +2362,7 @@ export async function transfer(client, parameters) {
|
|
|
2210
2362
|
})();
|
|
2211
2363
|
return defineCall({
|
|
2212
2364
|
address: TokenId.toAddress(token),
|
|
2213
|
-
abi:
|
|
2365
|
+
abi: Abis.tip20,
|
|
2214
2366
|
...callArgs,
|
|
2215
2367
|
});
|
|
2216
2368
|
}
|
|
@@ -2223,7 +2375,7 @@ export async function transfer(client, parameters) {
|
|
|
2223
2375
|
*/
|
|
2224
2376
|
function extractEvent(logs) {
|
|
2225
2377
|
const [log] = parseEventLogs({
|
|
2226
|
-
abi:
|
|
2378
|
+
abi: Abis.tip20,
|
|
2227
2379
|
logs,
|
|
2228
2380
|
eventName: 'Transfer',
|
|
2229
2381
|
});
|
|
@@ -2302,9 +2454,10 @@ export async function unpause(client, parameters) {
|
|
|
2302
2454
|
(function (unpause) {
|
|
2303
2455
|
/** @internal */
|
|
2304
2456
|
async function inner(action, client, parameters) {
|
|
2305
|
-
const
|
|
2457
|
+
const { token, ...rest } = parameters;
|
|
2458
|
+
const call = unpause.call({ token });
|
|
2306
2459
|
return (await action(client, {
|
|
2307
|
-
...
|
|
2460
|
+
...rest,
|
|
2308
2461
|
...call,
|
|
2309
2462
|
}));
|
|
2310
2463
|
}
|
|
@@ -2344,7 +2497,7 @@ export async function unpause(client, parameters) {
|
|
|
2344
2497
|
const { token } = args;
|
|
2345
2498
|
return defineCall({
|
|
2346
2499
|
address: TokenId.toAddress(token),
|
|
2347
|
-
abi:
|
|
2500
|
+
abi: Abis.tip20,
|
|
2348
2501
|
functionName: 'unpause',
|
|
2349
2502
|
args: [],
|
|
2350
2503
|
});
|
|
@@ -2358,7 +2511,7 @@ export async function unpause(client, parameters) {
|
|
|
2358
2511
|
*/
|
|
2359
2512
|
function extractEvent(logs) {
|
|
2360
2513
|
const [log] = parseEventLogs({
|
|
2361
|
-
abi:
|
|
2514
|
+
abi: Abis.tip20,
|
|
2362
2515
|
logs,
|
|
2363
2516
|
eventName: 'PauseStateUpdate',
|
|
2364
2517
|
});
|
|
@@ -2405,6 +2558,140 @@ export async function unpauseSync(client, parameters) {
|
|
|
2405
2558
|
receipt,
|
|
2406
2559
|
};
|
|
2407
2560
|
}
|
|
2561
|
+
/**
|
|
2562
|
+
* Updates the quote token for a TIP20 token.
|
|
2563
|
+
*
|
|
2564
|
+
* @example
|
|
2565
|
+
* ```ts
|
|
2566
|
+
* import { createClient, http } from 'viem'
|
|
2567
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
2568
|
+
* import * as actions from 'tempo.ts/viem/actions'
|
|
2569
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
2570
|
+
*
|
|
2571
|
+
* const client = createClient({
|
|
2572
|
+
* account: privateKeyToAccount('0x...'),
|
|
2573
|
+
* chain: tempo,
|
|
2574
|
+
* transport: http(),
|
|
2575
|
+
* })
|
|
2576
|
+
*
|
|
2577
|
+
* const result = await actions.token.updateQuoteToken(client, {
|
|
2578
|
+
* token: '0x...',
|
|
2579
|
+
* quoteToken: '0x...',
|
|
2580
|
+
* })
|
|
2581
|
+
* ```
|
|
2582
|
+
*
|
|
2583
|
+
* @param client - Client.
|
|
2584
|
+
* @param parameters - Parameters.
|
|
2585
|
+
* @returns The transaction hash.
|
|
2586
|
+
*/
|
|
2587
|
+
export async function updateQuoteToken(client, parameters) {
|
|
2588
|
+
return updateQuoteToken.inner(writeContract, client, parameters);
|
|
2589
|
+
}
|
|
2590
|
+
(function (updateQuoteToken) {
|
|
2591
|
+
/** @internal */
|
|
2592
|
+
async function inner(action, client, parameters) {
|
|
2593
|
+
const { quoteToken, token, ...rest } = parameters;
|
|
2594
|
+
const call = updateQuoteToken.call({ quoteToken, token });
|
|
2595
|
+
return (await action(client, {
|
|
2596
|
+
...rest,
|
|
2597
|
+
...call,
|
|
2598
|
+
}));
|
|
2599
|
+
}
|
|
2600
|
+
updateQuoteToken.inner = inner;
|
|
2601
|
+
/**
|
|
2602
|
+
* Defines a call to the `updateQuoteToken` function.
|
|
2603
|
+
*
|
|
2604
|
+
* Can be passed as a parameter to:
|
|
2605
|
+
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
2606
|
+
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
2607
|
+
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
2608
|
+
*
|
|
2609
|
+
* @example
|
|
2610
|
+
* ```ts
|
|
2611
|
+
* import { createClient, http, walletActions } from 'viem'
|
|
2612
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
2613
|
+
* import * as actions from 'tempo.ts/viem/actions'
|
|
2614
|
+
*
|
|
2615
|
+
* const client = createClient({
|
|
2616
|
+
* chain: tempo,
|
|
2617
|
+
* transport: http(),
|
|
2618
|
+
* }).extend(walletActions)
|
|
2619
|
+
*
|
|
2620
|
+
* const { result } = await client.sendCalls({
|
|
2621
|
+
* calls: [
|
|
2622
|
+
* actions.token.updateQuoteToken.call({
|
|
2623
|
+
* token: '0x20c0...babe',
|
|
2624
|
+
* quoteToken: '0x20c0...cafe',
|
|
2625
|
+
* }),
|
|
2626
|
+
* ]
|
|
2627
|
+
* })
|
|
2628
|
+
* ```
|
|
2629
|
+
*
|
|
2630
|
+
* @param args - Arguments.
|
|
2631
|
+
* @returns The call.
|
|
2632
|
+
*/
|
|
2633
|
+
function call(args) {
|
|
2634
|
+
const { token, quoteToken } = args;
|
|
2635
|
+
return defineCall({
|
|
2636
|
+
address: TokenId.toAddress(token),
|
|
2637
|
+
abi: Abis.tip20,
|
|
2638
|
+
functionName: 'updateQuoteToken',
|
|
2639
|
+
args: [TokenId.toAddress(quoteToken)],
|
|
2640
|
+
});
|
|
2641
|
+
}
|
|
2642
|
+
updateQuoteToken.call = call;
|
|
2643
|
+
/**
|
|
2644
|
+
* Extracts the event from the logs.
|
|
2645
|
+
*
|
|
2646
|
+
* @param logs - Logs.
|
|
2647
|
+
* @returns The event.
|
|
2648
|
+
*/
|
|
2649
|
+
function extractEvent(logs) {
|
|
2650
|
+
const [log] = parseEventLogs({
|
|
2651
|
+
abi: Abis.tip20,
|
|
2652
|
+
logs,
|
|
2653
|
+
eventName: 'UpdateQuoteToken',
|
|
2654
|
+
});
|
|
2655
|
+
if (!log)
|
|
2656
|
+
throw new Error('`UpdateQuoteToken` event not found.');
|
|
2657
|
+
return log;
|
|
2658
|
+
}
|
|
2659
|
+
updateQuoteToken.extractEvent = extractEvent;
|
|
2660
|
+
})(updateQuoteToken || (updateQuoteToken = {}));
|
|
2661
|
+
/**
|
|
2662
|
+
* Updates the quote token for a TIP20 token.
|
|
2663
|
+
*
|
|
2664
|
+
* @example
|
|
2665
|
+
* ```ts
|
|
2666
|
+
* import { createClient, http } from 'viem'
|
|
2667
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
2668
|
+
* import * as actions from 'tempo.ts/viem/actions'
|
|
2669
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
2670
|
+
*
|
|
2671
|
+
* const client = createClient({
|
|
2672
|
+
* account: privateKeyToAccount('0x...'),
|
|
2673
|
+
* chain: tempo,
|
|
2674
|
+
* transport: http(),
|
|
2675
|
+
* })
|
|
2676
|
+
*
|
|
2677
|
+
* const result = await actions.token.updateQuoteTokenSync(client, {
|
|
2678
|
+
* token: '0x...',
|
|
2679
|
+
* quoteToken: '0x...',
|
|
2680
|
+
* })
|
|
2681
|
+
* ```
|
|
2682
|
+
*
|
|
2683
|
+
* @param client - Client.
|
|
2684
|
+
* @param parameters - Parameters.
|
|
2685
|
+
* @returns The transaction receipt and event data.
|
|
2686
|
+
*/
|
|
2687
|
+
export async function updateQuoteTokenSync(client, parameters) {
|
|
2688
|
+
const receipt = await updateQuoteToken.inner(writeContractSync, client, parameters);
|
|
2689
|
+
const { args } = updateQuoteToken.extractEvent(receipt.logs);
|
|
2690
|
+
return {
|
|
2691
|
+
...args,
|
|
2692
|
+
receipt,
|
|
2693
|
+
};
|
|
2694
|
+
}
|
|
2408
2695
|
/**
|
|
2409
2696
|
* Watches for TIP20 token approval events.
|
|
2410
2697
|
*
|
|
@@ -2431,11 +2718,11 @@ export async function unpauseSync(client, parameters) {
|
|
|
2431
2718
|
* @returns A function to unsubscribe from the event.
|
|
2432
2719
|
*/
|
|
2433
2720
|
export function watchApprove(client, parameters) {
|
|
2434
|
-
const { onApproval, token =
|
|
2721
|
+
const { onApproval, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
2435
2722
|
return watchContractEvent(client, {
|
|
2436
2723
|
...rest,
|
|
2437
2724
|
address: TokenId.toAddress(token),
|
|
2438
|
-
abi:
|
|
2725
|
+
abi: Abis.tip20,
|
|
2439
2726
|
eventName: 'Approval',
|
|
2440
2727
|
onLogs: (logs) => {
|
|
2441
2728
|
for (const log of logs)
|
|
@@ -2470,11 +2757,11 @@ export function watchApprove(client, parameters) {
|
|
|
2470
2757
|
* @returns A function to unsubscribe from the event.
|
|
2471
2758
|
*/
|
|
2472
2759
|
export function watchBurn(client, parameters) {
|
|
2473
|
-
const { onBurn, token =
|
|
2760
|
+
const { onBurn, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
2474
2761
|
return watchContractEvent(client, {
|
|
2475
2762
|
...rest,
|
|
2476
2763
|
address: TokenId.toAddress(token),
|
|
2477
|
-
abi:
|
|
2764
|
+
abi: Abis.tip20,
|
|
2478
2765
|
eventName: 'Burn',
|
|
2479
2766
|
onLogs: (logs) => {
|
|
2480
2767
|
for (const log of logs)
|
|
@@ -2512,8 +2799,8 @@ export function watchCreate(client, parameters) {
|
|
|
2512
2799
|
const { onTokenCreated, ...rest } = parameters;
|
|
2513
2800
|
return watchContractEvent(client, {
|
|
2514
2801
|
...rest,
|
|
2515
|
-
address:
|
|
2516
|
-
abi:
|
|
2802
|
+
address: Addresses.tip20Factory,
|
|
2803
|
+
abi: Abis.tip20Factory,
|
|
2517
2804
|
eventName: 'TokenCreated',
|
|
2518
2805
|
onLogs: (logs) => {
|
|
2519
2806
|
for (const log of logs)
|
|
@@ -2548,11 +2835,11 @@ export function watchCreate(client, parameters) {
|
|
|
2548
2835
|
* @returns A function to unsubscribe from the event.
|
|
2549
2836
|
*/
|
|
2550
2837
|
export function watchMint(client, parameters) {
|
|
2551
|
-
const { onMint, token =
|
|
2838
|
+
const { onMint, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
2552
2839
|
return watchContractEvent(client, {
|
|
2553
2840
|
...rest,
|
|
2554
2841
|
address: TokenId.toAddress(token),
|
|
2555
|
-
abi:
|
|
2842
|
+
abi: Abis.tip20,
|
|
2556
2843
|
eventName: 'Mint',
|
|
2557
2844
|
onLogs: (logs) => {
|
|
2558
2845
|
for (const log of logs)
|
|
@@ -2587,11 +2874,11 @@ export function watchMint(client, parameters) {
|
|
|
2587
2874
|
* @returns A function to unsubscribe from the event.
|
|
2588
2875
|
*/
|
|
2589
2876
|
export function watchAdminRole(client, parameters) {
|
|
2590
|
-
const { onRoleAdminUpdated, token =
|
|
2877
|
+
const { onRoleAdminUpdated, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
2591
2878
|
return watchContractEvent(client, {
|
|
2592
2879
|
...rest,
|
|
2593
2880
|
address: TokenId.toAddress(token),
|
|
2594
|
-
abi:
|
|
2881
|
+
abi: Abis.tip20,
|
|
2595
2882
|
eventName: 'RoleAdminUpdated',
|
|
2596
2883
|
onLogs: (logs) => {
|
|
2597
2884
|
for (const log of logs)
|
|
@@ -2626,11 +2913,11 @@ export function watchAdminRole(client, parameters) {
|
|
|
2626
2913
|
* @returns A function to unsubscribe from the event.
|
|
2627
2914
|
*/
|
|
2628
2915
|
export function watchRole(client, parameters) {
|
|
2629
|
-
const { onRoleUpdated, token =
|
|
2916
|
+
const { onRoleUpdated, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
2630
2917
|
return watchContractEvent(client, {
|
|
2631
2918
|
...rest,
|
|
2632
2919
|
address: TokenId.toAddress(token),
|
|
2633
|
-
abi:
|
|
2920
|
+
abi: Abis.tip20,
|
|
2634
2921
|
eventName: 'RoleMembershipUpdated',
|
|
2635
2922
|
onLogs: (logs) => {
|
|
2636
2923
|
for (const log of logs) {
|
|
@@ -2668,11 +2955,11 @@ export function watchRole(client, parameters) {
|
|
|
2668
2955
|
* @returns A function to unsubscribe from the event.
|
|
2669
2956
|
*/
|
|
2670
2957
|
export function watchTransfer(client, parameters) {
|
|
2671
|
-
const { onTransfer, token =
|
|
2958
|
+
const { onTransfer, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
2672
2959
|
return watchContractEvent(client, {
|
|
2673
2960
|
...rest,
|
|
2674
2961
|
address: TokenId.toAddress(token),
|
|
2675
|
-
abi:
|
|
2962
|
+
abi: Abis.tip20,
|
|
2676
2963
|
eventName: 'Transfer',
|
|
2677
2964
|
onLogs: (logs) => {
|
|
2678
2965
|
for (const log of logs)
|
|
@@ -2681,4 +2968,53 @@ export function watchTransfer(client, parameters) {
|
|
|
2681
2968
|
strict: true,
|
|
2682
2969
|
});
|
|
2683
2970
|
}
|
|
2971
|
+
/**
|
|
2972
|
+
* Watches for TIP20 token quote token update events.
|
|
2973
|
+
*
|
|
2974
|
+
* @example
|
|
2975
|
+
* ```ts
|
|
2976
|
+
* import { createClient, http } from 'viem'
|
|
2977
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
2978
|
+
* import * as actions from 'tempo.ts/viem/actions'
|
|
2979
|
+
*
|
|
2980
|
+
* const client = createClient({
|
|
2981
|
+
* chain: tempo,
|
|
2982
|
+
* transport: http(),
|
|
2983
|
+
* })
|
|
2984
|
+
*
|
|
2985
|
+
* const unwatch = actions.token.watchUpdateQuoteToken(client, {
|
|
2986
|
+
* onUpdateQuoteToken: (args, log) => {
|
|
2987
|
+
* if (args.finalized)
|
|
2988
|
+
* console.log('quote token update finalized:', args.newQuoteToken)
|
|
2989
|
+
* else
|
|
2990
|
+
* console.log('quote token update proposed:', args.newQuoteToken)
|
|
2991
|
+
* },
|
|
2992
|
+
* })
|
|
2993
|
+
* ```
|
|
2994
|
+
*
|
|
2995
|
+
* @param client - Client.
|
|
2996
|
+
* @param parameters - Parameters.
|
|
2997
|
+
* @returns A function to unsubscribe from the event.
|
|
2998
|
+
*/
|
|
2999
|
+
export function watchUpdateQuoteToken(client, parameters) {
|
|
3000
|
+
const { onUpdateQuoteToken, token = Addresses.defaultFeeToken, ...rest } = parameters;
|
|
3001
|
+
const address = TokenId.toAddress(token);
|
|
3002
|
+
return watchContractEvent(client, {
|
|
3003
|
+
...rest,
|
|
3004
|
+
address,
|
|
3005
|
+
abi: Abis.tip20,
|
|
3006
|
+
onLogs: (logs) => {
|
|
3007
|
+
for (const log of logs) {
|
|
3008
|
+
if (log.eventName !== 'UpdateQuoteToken' &&
|
|
3009
|
+
log.eventName !== 'QuoteTokenUpdateFinalized')
|
|
3010
|
+
continue;
|
|
3011
|
+
onUpdateQuoteToken({
|
|
3012
|
+
...log.args,
|
|
3013
|
+
finalized: log.eventName === 'QuoteTokenUpdateFinalized',
|
|
3014
|
+
}, log);
|
|
3015
|
+
}
|
|
3016
|
+
},
|
|
3017
|
+
strict: true,
|
|
3018
|
+
});
|
|
3019
|
+
}
|
|
2684
3020
|
//# sourceMappingURL=token.js.map
|