tempo.ts 0.0.2 → 0.0.4
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/ox/TokenRole.d.ts +1 -1
- package/dist/ox/TokenRole.d.ts.map +1 -1
- package/dist/viem/abis.d.ts +763 -1454
- package/dist/viem/abis.d.ts.map +1 -1
- package/dist/viem/abis.js +486 -1224
- package/dist/viem/abis.js.map +1 -1
- package/dist/viem/actions/amm.d.ts +630 -715
- package/dist/viem/actions/amm.d.ts.map +1 -1
- package/dist/viem/actions/amm.js +15 -3
- package/dist/viem/actions/amm.js.map +1 -1
- package/dist/viem/actions/fee.d.ts +65 -418
- package/dist/viem/actions/fee.d.ts.map +1 -1
- package/dist/viem/actions/fee.js +5 -1
- package/dist/viem/actions/fee.js.map +1 -1
- package/dist/viem/actions/policy.d.ts +365 -593
- package/dist/viem/actions/policy.d.ts.map +1 -1
- package/dist/viem/actions/policy.js +29 -8
- package/dist/viem/actions/policy.js.map +1 -1
- package/dist/viem/actions/token.d.ts +4768 -7384
- package/dist/viem/actions/token.d.ts.map +1 -1
- package/dist/viem/actions/token.js +129 -20
- package/dist/viem/actions/token.js.map +1 -1
- package/dist/viem/decorator.d.ts +23 -0
- package/dist/viem/decorator.d.ts.map +1 -1
- package/dist/viem/decorator.js +1 -0
- package/dist/viem/decorator.js.map +1 -1
- package/dist/viem/types.d.ts +2 -2
- package/dist/viem/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/ox/TokenRole.test.ts +0 -4
- package/src/ox/TokenRole.ts +1 -1
- package/src/viem/abis.ts +495 -1234
- package/src/viem/actions/amm.ts +15 -7
- package/src/viem/actions/fee.ts +5 -5
- package/src/viem/actions/policy.ts +29 -16
- package/src/viem/actions/token.test.ts +190 -0
- package/src/viem/actions/token.ts +166 -47
- package/src/viem/client.test.ts +1 -0
- package/src/viem/decorator.bench-d.ts +1 -1
- package/src/viem/decorator.ts +26 -0
- package/src/viem/types.ts +3 -2
package/src/viem/actions/amm.ts
CHANGED
|
@@ -484,11 +484,11 @@ export async function rebalanceSwapSync<
|
|
|
484
484
|
client: Client<Transport, chain, account>,
|
|
485
485
|
parameters: rebalanceSwapSync.Parameters<chain, account>,
|
|
486
486
|
): Promise<rebalanceSwapSync.ReturnValue> {
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
)
|
|
487
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
488
|
+
const receipt = await rebalanceSwap.inner(writeContractSync, client, {
|
|
489
|
+
...rest,
|
|
490
|
+
throwOnReceiptRevert,
|
|
491
|
+
} as never)
|
|
492
492
|
const { args } = rebalanceSwap.extractEvent(receipt.logs)
|
|
493
493
|
return {
|
|
494
494
|
...args,
|
|
@@ -727,7 +727,11 @@ export async function mintSync<
|
|
|
727
727
|
client: Client<Transport, chain, account>,
|
|
728
728
|
parameters: mintSync.Parameters<chain, account>,
|
|
729
729
|
): Promise<mintSync.ReturnValue> {
|
|
730
|
-
const
|
|
730
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
731
|
+
const receipt = await mint.inner(writeContractSync, client, {
|
|
732
|
+
...rest,
|
|
733
|
+
throwOnReceiptRevert,
|
|
734
|
+
} as never)
|
|
731
735
|
const { args } = mint.extractEvent(receipt.logs)
|
|
732
736
|
return {
|
|
733
737
|
...args,
|
|
@@ -937,7 +941,11 @@ export async function burnSync<
|
|
|
937
941
|
client: Client<Transport, chain, account>,
|
|
938
942
|
parameters: burnSync.Parameters<chain, account>,
|
|
939
943
|
): Promise<burnSync.ReturnValue> {
|
|
940
|
-
const
|
|
944
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
945
|
+
const receipt = await burn.inner(writeContractSync, client, {
|
|
946
|
+
...rest,
|
|
947
|
+
throwOnReceiptRevert,
|
|
948
|
+
} as never)
|
|
941
949
|
const { args } = burn.extractEvent(receipt.logs)
|
|
942
950
|
return {
|
|
943
951
|
...args,
|
package/src/viem/actions/fee.ts
CHANGED
|
@@ -261,11 +261,11 @@ export async function setUserTokenSync<
|
|
|
261
261
|
client: Client<Transport, chain, account>,
|
|
262
262
|
parameters: setUserTokenSync.Parameters<chain, account>,
|
|
263
263
|
): Promise<setUserTokenSync.ReturnValue> {
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
)
|
|
264
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
265
|
+
const receipt = await setUserToken.inner(writeContractSync, client, {
|
|
266
|
+
...rest,
|
|
267
|
+
throwOnReceiptRevert,
|
|
268
|
+
} as never)
|
|
269
269
|
const { args } = setUserToken.extractEvent(receipt.logs)
|
|
270
270
|
return {
|
|
271
271
|
...args,
|
|
@@ -162,13 +162,18 @@ export namespace create {
|
|
|
162
162
|
export function call(args: Args) {
|
|
163
163
|
const { admin, type, addresses } = args
|
|
164
164
|
const callArgs = addresses
|
|
165
|
-
? (
|
|
166
|
-
|
|
165
|
+
? ({
|
|
166
|
+
functionName: 'createPolicyWithAccounts',
|
|
167
|
+
args: [admin, policyTypeMap[type], addresses],
|
|
168
|
+
} as const)
|
|
169
|
+
: ({
|
|
170
|
+
functionName: 'createPolicy',
|
|
171
|
+
args: [admin, policyTypeMap[type]],
|
|
172
|
+
} as const)
|
|
167
173
|
return defineCall({
|
|
168
174
|
address: tip403RegistryAddress,
|
|
169
175
|
abi: tip403RegistryAbi,
|
|
170
|
-
|
|
171
|
-
args: callArgs,
|
|
176
|
+
...callArgs,
|
|
172
177
|
})
|
|
173
178
|
}
|
|
174
179
|
|
|
@@ -223,7 +228,11 @@ export async function createSync<
|
|
|
223
228
|
client: Client<Transport, chain, account>,
|
|
224
229
|
parameters: createSync.Parameters<chain, account>,
|
|
225
230
|
): Promise<createSync.ReturnValue> {
|
|
226
|
-
const
|
|
231
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
232
|
+
const receipt = await create.inner(writeContractSync, client, {
|
|
233
|
+
...rest,
|
|
234
|
+
throwOnReceiptRevert,
|
|
235
|
+
} as never)
|
|
227
236
|
const { args } = create.extractEvent(receipt.logs)
|
|
228
237
|
return {
|
|
229
238
|
...args,
|
|
@@ -415,7 +424,11 @@ export async function setAdminSync<
|
|
|
415
424
|
client: Client<Transport, chain, account>,
|
|
416
425
|
parameters: setAdminSync.Parameters<chain, account>,
|
|
417
426
|
): Promise<setAdminSync.ReturnValue> {
|
|
418
|
-
const
|
|
427
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
428
|
+
const receipt = await setAdmin.inner(writeContractSync, client, {
|
|
429
|
+
...rest,
|
|
430
|
+
throwOnReceiptRevert,
|
|
431
|
+
} as never)
|
|
419
432
|
const { args } = setAdmin.extractEvent(receipt.logs)
|
|
420
433
|
return {
|
|
421
434
|
...args,
|
|
@@ -614,11 +627,11 @@ export async function modifyWhitelistSync<
|
|
|
614
627
|
client: Client<Transport, chain, account>,
|
|
615
628
|
parameters: modifyWhitelistSync.Parameters<chain, account>,
|
|
616
629
|
): Promise<modifyWhitelistSync.ReturnValue> {
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
)
|
|
630
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
631
|
+
const receipt = await modifyWhitelist.inner(writeContractSync, client, {
|
|
632
|
+
...rest,
|
|
633
|
+
throwOnReceiptRevert,
|
|
634
|
+
} as never)
|
|
622
635
|
const { args } = modifyWhitelist.extractEvent(receipt.logs)
|
|
623
636
|
return {
|
|
624
637
|
...args,
|
|
@@ -817,11 +830,11 @@ export async function modifyBlacklistSync<
|
|
|
817
830
|
client: Client<Transport, chain, account>,
|
|
818
831
|
parameters: modifyBlacklistSync.Parameters<chain, account>,
|
|
819
832
|
): Promise<modifyBlacklistSync.ReturnValue> {
|
|
820
|
-
const
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
)
|
|
833
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
834
|
+
const receipt = await modifyBlacklist.inner(writeContractSync, client, {
|
|
835
|
+
...rest,
|
|
836
|
+
throwOnReceiptRevert,
|
|
837
|
+
} as never)
|
|
825
838
|
const { args } = modifyBlacklist.extractEvent(receipt.logs)
|
|
826
839
|
return {
|
|
827
840
|
...args,
|
|
@@ -1087,6 +1087,196 @@ describe('unpause', () => {
|
|
|
1087
1087
|
|
|
1088
1088
|
describe.todo('setTokenSupplyCap')
|
|
1089
1089
|
|
|
1090
|
+
describe('hasRole', () => {
|
|
1091
|
+
test('default', async () => {
|
|
1092
|
+
// Create a new token where we're the admin
|
|
1093
|
+
const { token: address } = await actions.token.createSync(client, {
|
|
1094
|
+
currency: 'USD',
|
|
1095
|
+
name: 'HasRole Test Token',
|
|
1096
|
+
symbol: 'HRTEST',
|
|
1097
|
+
})
|
|
1098
|
+
|
|
1099
|
+
// Client account should have defaultAdmin role on the new token
|
|
1100
|
+
const hasDefaultAdminRole = await actions.token.hasRole(client, {
|
|
1101
|
+
token: address,
|
|
1102
|
+
role: 'defaultAdmin',
|
|
1103
|
+
})
|
|
1104
|
+
expect(hasDefaultAdminRole).toBe(true)
|
|
1105
|
+
|
|
1106
|
+
// Client account should not have issuer role initially on the new token
|
|
1107
|
+
const hasIssuerRole = await actions.token.hasRole(client, {
|
|
1108
|
+
token: address,
|
|
1109
|
+
role: 'issuer',
|
|
1110
|
+
})
|
|
1111
|
+
expect(hasIssuerRole).toBe(false)
|
|
1112
|
+
|
|
1113
|
+
// Grant issuer role
|
|
1114
|
+
await actions.token.grantRolesSync(client, {
|
|
1115
|
+
token: address,
|
|
1116
|
+
roles: ['issuer'],
|
|
1117
|
+
to: client.account.address,
|
|
1118
|
+
})
|
|
1119
|
+
|
|
1120
|
+
// Now should have issuer role
|
|
1121
|
+
const hasIssuerRoleAfterGrant = await actions.token.hasRole(client, {
|
|
1122
|
+
token: address,
|
|
1123
|
+
role: 'issuer',
|
|
1124
|
+
})
|
|
1125
|
+
expect(hasIssuerRoleAfterGrant).toBe(true)
|
|
1126
|
+
})
|
|
1127
|
+
|
|
1128
|
+
test('behavior: check other account', async () => {
|
|
1129
|
+
// Create a new token
|
|
1130
|
+
const { token: address } = await actions.token.createSync(client, {
|
|
1131
|
+
currency: 'USD',
|
|
1132
|
+
name: 'HasRole Other Account',
|
|
1133
|
+
symbol: 'HROAC',
|
|
1134
|
+
})
|
|
1135
|
+
|
|
1136
|
+
// Account2 should not have issuer role
|
|
1137
|
+
const hasIssuerBefore = await actions.token.hasRole(client, {
|
|
1138
|
+
token: address,
|
|
1139
|
+
account: account2.address,
|
|
1140
|
+
role: 'issuer',
|
|
1141
|
+
})
|
|
1142
|
+
expect(hasIssuerBefore).toBe(false)
|
|
1143
|
+
|
|
1144
|
+
// Grant issuer role to account2
|
|
1145
|
+
await actions.token.grantRolesSync(client, {
|
|
1146
|
+
token: address,
|
|
1147
|
+
roles: ['issuer'],
|
|
1148
|
+
to: account2.address,
|
|
1149
|
+
})
|
|
1150
|
+
|
|
1151
|
+
// Account2 should now have issuer role
|
|
1152
|
+
const hasIssuerAfter = await actions.token.hasRole(client, {
|
|
1153
|
+
token: address,
|
|
1154
|
+
account: account2.address,
|
|
1155
|
+
role: 'issuer',
|
|
1156
|
+
})
|
|
1157
|
+
expect(hasIssuerAfter).toBe(true)
|
|
1158
|
+
|
|
1159
|
+
// Account3 should still not have issuer role
|
|
1160
|
+
const account3HasIssuer = await actions.token.hasRole(client, {
|
|
1161
|
+
token: address,
|
|
1162
|
+
account: account3.address,
|
|
1163
|
+
role: 'issuer',
|
|
1164
|
+
})
|
|
1165
|
+
expect(account3HasIssuer).toBe(false)
|
|
1166
|
+
})
|
|
1167
|
+
|
|
1168
|
+
test('behavior: multiple roles', async () => {
|
|
1169
|
+
// Create a new token
|
|
1170
|
+
const { token: address } = await actions.token.createSync(client, {
|
|
1171
|
+
currency: 'USD',
|
|
1172
|
+
name: 'HasRole Multiple',
|
|
1173
|
+
symbol: 'HRMULTI',
|
|
1174
|
+
})
|
|
1175
|
+
|
|
1176
|
+
// Grant multiple roles to account2
|
|
1177
|
+
await actions.token.grantRolesSync(client, {
|
|
1178
|
+
token: address,
|
|
1179
|
+
roles: ['issuer', 'pause'],
|
|
1180
|
+
to: account2.address,
|
|
1181
|
+
})
|
|
1182
|
+
|
|
1183
|
+
// Check issuer role
|
|
1184
|
+
const hasIssuer = await actions.token.hasRole(client, {
|
|
1185
|
+
token: address,
|
|
1186
|
+
account: account2.address,
|
|
1187
|
+
role: 'issuer',
|
|
1188
|
+
})
|
|
1189
|
+
expect(hasIssuer).toBe(true)
|
|
1190
|
+
|
|
1191
|
+
// Check pause role
|
|
1192
|
+
const hasPause = await actions.token.hasRole(client, {
|
|
1193
|
+
token: address,
|
|
1194
|
+
account: account2.address,
|
|
1195
|
+
role: 'pause',
|
|
1196
|
+
})
|
|
1197
|
+
expect(hasPause).toBe(true)
|
|
1198
|
+
|
|
1199
|
+
// Check unpause role (not granted)
|
|
1200
|
+
const hasUnpause = await actions.token.hasRole(client, {
|
|
1201
|
+
token: address,
|
|
1202
|
+
account: account2.address,
|
|
1203
|
+
role: 'unpause',
|
|
1204
|
+
})
|
|
1205
|
+
expect(hasUnpause).toBe(false)
|
|
1206
|
+
})
|
|
1207
|
+
|
|
1208
|
+
test('behavior: after revoke', async () => {
|
|
1209
|
+
// Create a new token
|
|
1210
|
+
const { token: address } = await actions.token.createSync(client, {
|
|
1211
|
+
currency: 'USD',
|
|
1212
|
+
name: 'HasRole Revoke',
|
|
1213
|
+
symbol: 'HRREV',
|
|
1214
|
+
})
|
|
1215
|
+
|
|
1216
|
+
// Grant issuer role to account2
|
|
1217
|
+
await actions.token.grantRolesSync(client, {
|
|
1218
|
+
token: address,
|
|
1219
|
+
roles: ['issuer'],
|
|
1220
|
+
to: account2.address,
|
|
1221
|
+
})
|
|
1222
|
+
|
|
1223
|
+
// Verify has role
|
|
1224
|
+
const hasRoleBefore = await actions.token.hasRole(client, {
|
|
1225
|
+
token: address,
|
|
1226
|
+
account: account2.address,
|
|
1227
|
+
role: 'issuer',
|
|
1228
|
+
})
|
|
1229
|
+
expect(hasRoleBefore).toBe(true)
|
|
1230
|
+
|
|
1231
|
+
// Revoke the role
|
|
1232
|
+
await actions.token.revokeRolesSync(client, {
|
|
1233
|
+
token: address,
|
|
1234
|
+
roles: ['issuer'],
|
|
1235
|
+
from: account2.address,
|
|
1236
|
+
})
|
|
1237
|
+
|
|
1238
|
+
// Verify no longer has role
|
|
1239
|
+
const hasRoleAfter = await actions.token.hasRole(client, {
|
|
1240
|
+
token: address,
|
|
1241
|
+
account: account2.address,
|
|
1242
|
+
role: 'issuer',
|
|
1243
|
+
})
|
|
1244
|
+
expect(hasRoleAfter).toBe(false)
|
|
1245
|
+
})
|
|
1246
|
+
|
|
1247
|
+
test('behavior: with token ID', async () => {
|
|
1248
|
+
// Create a new token
|
|
1249
|
+
const { token: address, tokenId } = await actions.token.createSync(client, {
|
|
1250
|
+
currency: 'USD',
|
|
1251
|
+
name: 'HasRole Token ID',
|
|
1252
|
+
symbol: 'HRTID',
|
|
1253
|
+
})
|
|
1254
|
+
|
|
1255
|
+
// Grant issuer role
|
|
1256
|
+
await actions.token.grantRolesSync(client, {
|
|
1257
|
+
token: tokenId,
|
|
1258
|
+
roles: ['issuer'],
|
|
1259
|
+
to: account2.address,
|
|
1260
|
+
})
|
|
1261
|
+
|
|
1262
|
+
// Check using token ID
|
|
1263
|
+
const hasRole = await actions.token.hasRole(client, {
|
|
1264
|
+
token: tokenId,
|
|
1265
|
+
account: account2.address,
|
|
1266
|
+
role: 'issuer',
|
|
1267
|
+
})
|
|
1268
|
+
expect(hasRole).toBe(true)
|
|
1269
|
+
|
|
1270
|
+
// Verify same result with address
|
|
1271
|
+
const hasRoleWithAddress = await actions.token.hasRole(client, {
|
|
1272
|
+
token: address,
|
|
1273
|
+
account: account2.address,
|
|
1274
|
+
role: 'issuer',
|
|
1275
|
+
})
|
|
1276
|
+
expect(hasRoleWithAddress).toBe(true)
|
|
1277
|
+
})
|
|
1278
|
+
})
|
|
1279
|
+
|
|
1090
1280
|
describe('grantRoles', () => {
|
|
1091
1281
|
test('default', async () => {
|
|
1092
1282
|
// Create a new token where we're the admin
|
|
@@ -206,11 +206,20 @@ export async function approveSync<
|
|
|
206
206
|
client: Client<Transport, chain, account>,
|
|
207
207
|
parameters: approveSync.Parameters<chain, account>,
|
|
208
208
|
): Promise<approveSync.ReturnValue> {
|
|
209
|
-
const {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
209
|
+
const {
|
|
210
|
+
throwOnReceiptRevert = true,
|
|
211
|
+
token = usdAddress,
|
|
212
|
+
...rest
|
|
213
|
+
} = parameters
|
|
214
|
+
const receipt = await approve.inner(
|
|
215
|
+
writeContractSync,
|
|
216
|
+
client,
|
|
217
|
+
{ ...parameters, throwOnReceiptRevert } as never,
|
|
218
|
+
{
|
|
219
|
+
...rest,
|
|
220
|
+
token,
|
|
221
|
+
},
|
|
222
|
+
)
|
|
214
223
|
const { args } = approve.extractEvent(receipt.logs)
|
|
215
224
|
return {
|
|
216
225
|
...args,
|
|
@@ -406,7 +415,11 @@ export async function burnBlockedSync<
|
|
|
406
415
|
client: Client<Transport, chain, account>,
|
|
407
416
|
parameters: burnBlockedSync.Parameters<chain, account>,
|
|
408
417
|
): Promise<burnBlockedSync.ReturnValue> {
|
|
409
|
-
const
|
|
418
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
419
|
+
const receipt = await burnBlocked.inner(writeContractSync, client, {
|
|
420
|
+
...rest,
|
|
421
|
+
throwOnReceiptRevert,
|
|
422
|
+
} as never)
|
|
410
423
|
const { args } = burnBlocked.extractEvent(receipt.logs)
|
|
411
424
|
return {
|
|
412
425
|
...args,
|
|
@@ -607,7 +620,11 @@ export async function burnSync<
|
|
|
607
620
|
client: Client<Transport, chain, account>,
|
|
608
621
|
parameters: burnSync.Parameters<chain, account>,
|
|
609
622
|
): Promise<burnSync.ReturnValue> {
|
|
610
|
-
const
|
|
623
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
624
|
+
const receipt = await burn.inner(writeContractSync, client, {
|
|
625
|
+
...rest,
|
|
626
|
+
throwOnReceiptRevert,
|
|
627
|
+
} as never)
|
|
611
628
|
const { args } = burn.extractEvent(receipt.logs)
|
|
612
629
|
return {
|
|
613
630
|
...args,
|
|
@@ -797,11 +814,11 @@ export async function changeTransferPolicySync<
|
|
|
797
814
|
client: Client<Transport, chain, account>,
|
|
798
815
|
parameters: changeTransferPolicySync.Parameters<chain, account>,
|
|
799
816
|
): Promise<changeTransferPolicySync.ReturnValue> {
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
)
|
|
817
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
818
|
+
const receipt = await changeTransferPolicy.inner(writeContractSync, client, {
|
|
819
|
+
...rest,
|
|
820
|
+
throwOnReceiptRevert,
|
|
821
|
+
} as never)
|
|
805
822
|
const { args } = changeTransferPolicy.extractEvent(receipt.logs)
|
|
806
823
|
return {
|
|
807
824
|
...args,
|
|
@@ -1019,7 +1036,11 @@ export async function createSync<
|
|
|
1019
1036
|
client: Client<Transport, chain, account>,
|
|
1020
1037
|
parameters: createSync.Parameters<chain, account>,
|
|
1021
1038
|
): Promise<createSync.ReturnValue> {
|
|
1022
|
-
const
|
|
1039
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
1040
|
+
const receipt = await create.inner(writeContractSync, client, {
|
|
1041
|
+
...rest,
|
|
1042
|
+
throwOnReceiptRevert,
|
|
1043
|
+
} as never)
|
|
1023
1044
|
|
|
1024
1045
|
const { args } = create.extractEvent(receipt.logs)
|
|
1025
1046
|
|
|
@@ -1081,12 +1102,12 @@ export async function getAllowance<
|
|
|
1081
1102
|
client: Client<Transport, chain, account>,
|
|
1082
1103
|
parameters: getAllowance.Parameters<account>,
|
|
1083
1104
|
): Promise<getAllowance.ReturnValue> {
|
|
1084
|
-
const { account = client.account
|
|
1105
|
+
const { account = client.account } = parameters
|
|
1085
1106
|
const address = account ? parseAccount(account).address : undefined
|
|
1086
1107
|
if (!address) throw new Error('account is required.')
|
|
1087
1108
|
return readContract(client, {
|
|
1088
|
-
...
|
|
1089
|
-
...getAllowance.call({ account: address
|
|
1109
|
+
...parameters,
|
|
1110
|
+
...getAllowance.call({ ...parameters, account: address }),
|
|
1090
1111
|
})
|
|
1091
1112
|
}
|
|
1092
1113
|
|
|
@@ -1333,6 +1354,84 @@ export declare namespace getMetadata {
|
|
|
1333
1354
|
}>
|
|
1334
1355
|
}
|
|
1335
1356
|
|
|
1357
|
+
/**
|
|
1358
|
+
* Checks if an account has a specific role for a TIP20 token.
|
|
1359
|
+
*
|
|
1360
|
+
* @example
|
|
1361
|
+
* ```ts
|
|
1362
|
+
* import { createClient, http } from 'viem'
|
|
1363
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
1364
|
+
* import * as actions from 'tempo.ts/viem/actions'
|
|
1365
|
+
*
|
|
1366
|
+
* const client = createClient({
|
|
1367
|
+
* chain: tempo,
|
|
1368
|
+
* transport: http(),
|
|
1369
|
+
* })
|
|
1370
|
+
*
|
|
1371
|
+
* const hasRole = await actions.token.hasRole(client, {
|
|
1372
|
+
* account: '0x...',
|
|
1373
|
+
* role: 'issuer',
|
|
1374
|
+
* token: '0x...',
|
|
1375
|
+
* })
|
|
1376
|
+
* ```
|
|
1377
|
+
*
|
|
1378
|
+
* @param client - Client.
|
|
1379
|
+
* @param parameters - Parameters.
|
|
1380
|
+
* @returns Whether the account has the role.
|
|
1381
|
+
*/
|
|
1382
|
+
export async function hasRole<
|
|
1383
|
+
chain extends Chain | undefined,
|
|
1384
|
+
account extends Account | undefined,
|
|
1385
|
+
>(
|
|
1386
|
+
client: Client<Transport, chain, account>,
|
|
1387
|
+
parameters: hasRole.Parameters<account>,
|
|
1388
|
+
): Promise<hasRole.ReturnValue> {
|
|
1389
|
+
const { account = client.account } = parameters
|
|
1390
|
+
const address = account ? parseAccount(account).address : undefined
|
|
1391
|
+
if (!address) throw new Error('account is required.')
|
|
1392
|
+
return readContract(client, {
|
|
1393
|
+
...parameters,
|
|
1394
|
+
...hasRole.call({ ...parameters, account: address }),
|
|
1395
|
+
})
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
export namespace hasRole {
|
|
1399
|
+
export type Parameters<
|
|
1400
|
+
account extends Account | undefined = Account | undefined,
|
|
1401
|
+
> = ReadParameters & Omit<Args, 'account'> & GetAccountParameter<account>
|
|
1402
|
+
|
|
1403
|
+
export type Args = {
|
|
1404
|
+
/** Account address to check. */
|
|
1405
|
+
account: Address
|
|
1406
|
+
/** Role to check. */
|
|
1407
|
+
role: TokenRole.TokenRole
|
|
1408
|
+
/** Address or ID of the TIP20 token. */
|
|
1409
|
+
token: TokenId.TokenIdOrAddress
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
export type ReturnValue = ReadContractReturnType<
|
|
1413
|
+
typeof tip20Abi,
|
|
1414
|
+
'hasRole',
|
|
1415
|
+
never
|
|
1416
|
+
>
|
|
1417
|
+
|
|
1418
|
+
/**
|
|
1419
|
+
* Defines a call to the `hasRole` function.
|
|
1420
|
+
*
|
|
1421
|
+
* @param args - Arguments.
|
|
1422
|
+
* @returns The call.
|
|
1423
|
+
*/
|
|
1424
|
+
export function call(args: Args) {
|
|
1425
|
+
const { account, role, token } = args
|
|
1426
|
+
return defineCall({
|
|
1427
|
+
address: TokenId.toAddress(token),
|
|
1428
|
+
abi: tip20Abi,
|
|
1429
|
+
functionName: 'hasRole',
|
|
1430
|
+
args: [account, TokenRole.serialize(role)],
|
|
1431
|
+
})
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1336
1435
|
/**
|
|
1337
1436
|
* Grants a role for a TIP20 token.
|
|
1338
1437
|
*
|
|
@@ -1352,7 +1451,7 @@ export declare namespace getMetadata {
|
|
|
1352
1451
|
* const result = await actions.token.grantRoles(client, {
|
|
1353
1452
|
* token: '0x...',
|
|
1354
1453
|
* to: '0x...',
|
|
1355
|
-
* roles: ['
|
|
1454
|
+
* roles: ['issuer'],
|
|
1356
1455
|
* })
|
|
1357
1456
|
* ```
|
|
1358
1457
|
*
|
|
@@ -1509,11 +1608,11 @@ export async function grantRolesSync<
|
|
|
1509
1608
|
client: Client<Transport, chain, account>,
|
|
1510
1609
|
parameters: grantRolesSync.Parameters<chain, account>,
|
|
1511
1610
|
): Promise<grantRolesSync.ReturnValue> {
|
|
1512
|
-
const
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
)
|
|
1611
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
1612
|
+
const receipt = await grantRoles.inner(sendTransactionSync, client, {
|
|
1613
|
+
...rest,
|
|
1614
|
+
throwOnReceiptRevert,
|
|
1615
|
+
} as never)
|
|
1517
1616
|
const events = grantRoles.extractEvents(receipt.logs)
|
|
1518
1617
|
const value = events.map((event) => event.args)
|
|
1519
1618
|
return {
|
|
@@ -1716,7 +1815,11 @@ export async function mintSync<
|
|
|
1716
1815
|
client: Client<Transport, chain, account>,
|
|
1717
1816
|
parameters: mintSync.Parameters<chain, account>,
|
|
1718
1817
|
): Promise<mintSync.ReturnValue> {
|
|
1719
|
-
const
|
|
1818
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
1819
|
+
const receipt = await mint.inner(writeContractSync, client, {
|
|
1820
|
+
...rest,
|
|
1821
|
+
throwOnReceiptRevert,
|
|
1822
|
+
} as never)
|
|
1720
1823
|
const { args } = mint.extractEvent(receipt.logs)
|
|
1721
1824
|
return {
|
|
1722
1825
|
...args,
|
|
@@ -1901,7 +2004,11 @@ export async function pauseSync<
|
|
|
1901
2004
|
client: Client<Transport, chain, account>,
|
|
1902
2005
|
parameters: pauseSync.Parameters<chain, account>,
|
|
1903
2006
|
): Promise<pauseSync.ReturnValue> {
|
|
1904
|
-
const
|
|
2007
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
2008
|
+
const receipt = await pause.inner(writeContractSync, client, {
|
|
2009
|
+
...rest,
|
|
2010
|
+
throwOnReceiptRevert,
|
|
2011
|
+
} as never)
|
|
1905
2012
|
const { args } = pause.extractEvent(receipt.logs)
|
|
1906
2013
|
return {
|
|
1907
2014
|
...args,
|
|
@@ -2121,7 +2228,11 @@ export async function permitSync<
|
|
|
2121
2228
|
client: Client<Transport, chain, account>,
|
|
2122
2229
|
parameters: permitSync.Parameters<chain, account>,
|
|
2123
2230
|
): Promise<permitSync.ReturnValue> {
|
|
2124
|
-
const
|
|
2231
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
2232
|
+
const receipt = await permit.inner(writeContractSync, client, {
|
|
2233
|
+
...rest,
|
|
2234
|
+
throwOnReceiptRevert,
|
|
2235
|
+
} as never)
|
|
2125
2236
|
const { args } = permit.extractEvent(receipt.logs)
|
|
2126
2237
|
return {
|
|
2127
2238
|
...args,
|
|
@@ -2317,11 +2428,11 @@ export async function renounceRolesSync<
|
|
|
2317
2428
|
client: Client<Transport, chain, account>,
|
|
2318
2429
|
parameters: renounceRolesSync.Parameters<chain, account>,
|
|
2319
2430
|
): Promise<renounceRolesSync.ReturnValue> {
|
|
2320
|
-
const
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
)
|
|
2431
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
2432
|
+
const receipt = await renounceRoles.inner(sendTransactionSync, client, {
|
|
2433
|
+
...rest,
|
|
2434
|
+
throwOnReceiptRevert,
|
|
2435
|
+
} as never)
|
|
2325
2436
|
const events = renounceRoles.extractEvents(receipt.logs)
|
|
2326
2437
|
const value = events.map((event) => event.args)
|
|
2327
2438
|
return {
|
|
@@ -2524,11 +2635,11 @@ export async function revokeRolesSync<
|
|
|
2524
2635
|
client: Client<Transport, chain, account>,
|
|
2525
2636
|
parameters: revokeRolesSync.Parameters<chain, account>,
|
|
2526
2637
|
): Promise<revokeRolesSync.ReturnValue> {
|
|
2527
|
-
const
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
)
|
|
2638
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
2639
|
+
const receipt = await revokeRoles.inner(sendTransactionSync, client, {
|
|
2640
|
+
...rest,
|
|
2641
|
+
throwOnReceiptRevert,
|
|
2642
|
+
} as never)
|
|
2532
2643
|
const events = revokeRoles.extractEvents(receipt.logs)
|
|
2533
2644
|
const value = events.map((event) => event.args)
|
|
2534
2645
|
return {
|
|
@@ -2715,11 +2826,11 @@ export async function setSupplyCapSync<
|
|
|
2715
2826
|
client: Client<Transport, chain, account>,
|
|
2716
2827
|
parameters: setSupplyCapSync.Parameters<chain, account>,
|
|
2717
2828
|
): Promise<setSupplyCapSync.ReturnValue> {
|
|
2718
|
-
const
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
)
|
|
2829
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
2830
|
+
const receipt = await setSupplyCap.inner(writeContractSync, client, {
|
|
2831
|
+
...rest,
|
|
2832
|
+
throwOnReceiptRevert,
|
|
2833
|
+
} as never)
|
|
2723
2834
|
const { args } = setSupplyCap.extractEvent(receipt.logs)
|
|
2724
2835
|
return {
|
|
2725
2836
|
...args,
|
|
@@ -2911,11 +3022,11 @@ export async function setRoleAdminSync<
|
|
|
2911
3022
|
client: Client<Transport, chain, account>,
|
|
2912
3023
|
parameters: setRoleAdminSync.Parameters<chain, account>,
|
|
2913
3024
|
): Promise<setRoleAdminSync.ReturnValue> {
|
|
2914
|
-
const
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
)
|
|
3025
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
3026
|
+
const receipt = await setRoleAdmin.inner(writeContractSync, client, {
|
|
3027
|
+
...rest,
|
|
3028
|
+
throwOnReceiptRevert,
|
|
3029
|
+
} as never)
|
|
2919
3030
|
const { args } = setRoleAdmin.extractEvent(receipt.logs)
|
|
2920
3031
|
return {
|
|
2921
3032
|
...args,
|
|
@@ -3127,7 +3238,11 @@ export async function transferSync<
|
|
|
3127
3238
|
client: Client<Transport, chain, account>,
|
|
3128
3239
|
parameters: transferSync.Parameters<chain, account>,
|
|
3129
3240
|
): Promise<transferSync.ReturnValue> {
|
|
3130
|
-
const
|
|
3241
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
3242
|
+
const receipt = await transfer.inner(writeContractSync, client, {
|
|
3243
|
+
...rest,
|
|
3244
|
+
throwOnReceiptRevert,
|
|
3245
|
+
} as never)
|
|
3131
3246
|
const { args } = transfer.extractEvent(receipt.logs)
|
|
3132
3247
|
return {
|
|
3133
3248
|
...args,
|
|
@@ -3307,7 +3422,11 @@ export async function unpauseSync<
|
|
|
3307
3422
|
client: Client<Transport, chain, account>,
|
|
3308
3423
|
parameters: unpauseSync.Parameters<chain, account>,
|
|
3309
3424
|
): Promise<unpauseSync.ReturnValue> {
|
|
3310
|
-
const
|
|
3425
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
3426
|
+
const receipt = await unpause.inner(writeContractSync, client, {
|
|
3427
|
+
...rest,
|
|
3428
|
+
throwOnReceiptRevert,
|
|
3429
|
+
} as never)
|
|
3311
3430
|
const { args } = unpause.extractEvent(receipt.logs)
|
|
3312
3431
|
return {
|
|
3313
3432
|
...args,
|
package/src/viem/client.test.ts
CHANGED