@mysten/sui 2.22.0 → 2.23.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/CHANGELOG.md +47 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/bcs.d.mts.map +1 -1
- package/dist/bcs/bcs.mjs +1 -19
- package/dist/bcs/bcs.mjs.map +1 -1
- package/dist/bcs/index.d.mts +4225 -1319
- package/dist/bcs/index.d.mts.map +1 -1
- package/dist/bcs/index.mjs +2 -1
- package/dist/bcs/index.mjs.map +1 -1
- package/dist/bcs/transactions.mjs +147 -0
- package/dist/bcs/transactions.mjs.map +1 -0
- package/dist/client/address-balance-transaction-expiration.mjs +22 -0
- package/dist/client/address-balance-transaction-expiration.mjs.map +1 -0
- package/dist/client/core-resolver.mjs +2 -1
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/client/core.d.mts +2 -0
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/query-filters.mjs +119 -0
- package/dist/client/query-filters.mjs.map +1 -0
- package/dist/client/types.d.mts +166 -1
- package/dist/client/types.d.mts.map +1 -1
- package/dist/client/utils.d.mts.map +1 -1
- package/dist/client/utils.mjs +13 -1
- package/dist/client/utils.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/client.d.mts +15 -2
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +6 -0
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +5 -1
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +96 -4
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +140 -1
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +108 -0
- package/dist/graphql/index.d.mts +2 -2
- package/dist/grpc/client.d.mts +11 -0
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +6 -0
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +5 -1
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +113 -4
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/filters.mjs +45 -0
- package/dist/grpc/filters.mjs.map +1 -0
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/event.d.mts +31 -0
- package/dist/grpc/proto/sui/rpc/v2/event.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/event.mjs +30 -0
- package/dist/grpc/proto/sui/rpc/v2/event.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts +7 -0
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.mjs +8 -0
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/filter.d.mts +423 -0
- package/dist/grpc/proto/sui/rpc/v2/filter.d.mts.map +1 -0
- package/dist/grpc/proto/sui/rpc/v2/filter.mjs +297 -0
- package/dist/grpc/proto/sui/rpc/v2/filter.mjs.map +1 -0
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +62 -6
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.mjs +37 -0
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts +293 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +241 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/protocol_config.d.mts +15 -2
- package/dist/grpc/proto/sui/rpc/v2/protocol_config.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/protocol_config.mjs +11 -0
- package/dist/grpc/proto/sui/rpc/v2/protocol_config.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts +211 -0
- package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts.map +1 -0
- package/dist/grpc/proto/sui/rpc/v2/query_options.mjs +163 -0
- package/dist/grpc/proto/sui/rpc/v2/query_options.mjs.map +1 -0
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +105 -23
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs +56 -9
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.d.mts +148 -8
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.mjs +109 -8
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/grpc/proto/types.d.mts +5 -3
- package/dist/grpc/proto/types.mjs +33 -2
- package/dist/grpc/proto/types.mjs.map +1 -1
- package/dist/jsonRpc/core.d.mts +10 -0
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +85 -2
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +6 -6
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/intents/CoinWithBalance.mjs +14 -18
- package/dist/transactions/intents/CoinWithBalance.mjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/address.mjs +2 -2
- package/dist/zklogin/address.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/poseidon.mjs +5 -2
- package/dist/zklogin/poseidon.mjs.map +1 -1
- package/docs/clients/core.md +115 -1
- package/docs/clients/grpc.md +68 -0
- package/docs/migrations/sui-2.0/json-rpc-migration.md +104 -101
- package/package.json +2 -2
- package/src/bcs/bcs.ts +0 -27
- package/src/bcs/index.ts +7 -5
- package/src/bcs/transactions.ts +226 -0
- package/src/client/address-balance-transaction-expiration.ts +53 -0
- package/src/client/core-resolver.ts +5 -1
- package/src/client/core.ts +8 -0
- package/src/client/query-filters.ts +195 -0
- package/src/client/types.ts +186 -1
- package/src/client/utils.ts +13 -0
- package/src/graphql/client.ts +25 -1
- package/src/graphql/core.ts +156 -6
- package/src/graphql/generated/queries.ts +230 -1
- package/src/graphql/generated/schema.graphql +75 -0
- package/src/graphql/generated/tada-env.ts +133 -0
- package/src/graphql/index.ts +1 -0
- package/src/graphql/queries/listEvents.graphql +40 -0
- package/src/graphql/queries/transactions.graphql +29 -0
- package/src/grpc/client.ts +19 -0
- package/src/grpc/core.ts +201 -6
- package/src/grpc/filters.ts +68 -0
- package/src/grpc/proto/sui/rpc/v2/event.ts +49 -0
- package/src/grpc/proto/sui/rpc/v2/executed_transaction.ts +15 -0
- package/src/grpc/proto/sui/rpc/v2/filter.ts +589 -0
- package/src/grpc/proto/sui/rpc/v2/ledger_service.client.ts +111 -0
- package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +406 -0
- package/src/grpc/proto/sui/rpc/v2/protocol_config.ts +22 -2
- package/src/grpc/proto/sui/rpc/v2/query_options.ts +255 -0
- package/src/grpc/proto/sui/rpc/v2/subscription_service.client.ts +136 -18
- package/src/grpc/proto/sui/rpc/v2/subscription_service.ts +187 -7
- package/src/grpc/proto/types.ts +2 -0
- package/src/jsonRpc/core.ts +136 -2
- package/src/transactions/intents/CoinWithBalance.ts +41 -41
- package/src/version.ts +1 -1
- package/src/zklogin/address.ts +2 -2
- package/src/zklogin/poseidon.ts +6 -4
package/src/grpc/proto/types.ts
CHANGED
|
@@ -23,6 +23,7 @@ export * from './sui/rpc/v2/error_reason.js';
|
|
|
23
23
|
export * from './sui/rpc/v2/event.js';
|
|
24
24
|
export * from './sui/rpc/v2/executed_transaction.js';
|
|
25
25
|
export * from './sui/rpc/v2/execution_status.js';
|
|
26
|
+
export * from './sui/rpc/v2/filter.js';
|
|
26
27
|
export * from './sui/rpc/v2/gas_cost_summary.js';
|
|
27
28
|
export * from './sui/rpc/v2/input.js';
|
|
28
29
|
export * from './sui/rpc/v2/jwk.js';
|
|
@@ -34,6 +35,7 @@ export * from './sui/rpc/v2/object.js';
|
|
|
34
35
|
export * from './sui/rpc/v2/object_reference.js';
|
|
35
36
|
export * from './sui/rpc/v2/owner.js';
|
|
36
37
|
export * from './sui/rpc/v2/protocol_config.js';
|
|
38
|
+
export * from './sui/rpc/v2/query_options.js';
|
|
37
39
|
export * from './sui/rpc/v2/signature.js';
|
|
38
40
|
export * from './sui/rpc/v2/signature_scheme.js';
|
|
39
41
|
export * from './sui/rpc/v2/signature_verification_service.js';
|
package/src/jsonRpc/core.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { fromBase64, type InferBcsInput } from '@mysten/bcs';
|
|
4
|
+
import { fromBase58, fromBase64, type InferBcsInput } from '@mysten/bcs';
|
|
5
5
|
|
|
6
6
|
import { bcs, TypeTagSerializer } from '../bcs/index.js';
|
|
7
7
|
import type {
|
|
8
8
|
DevInspectResults,
|
|
9
9
|
DryRunTransactionBlockResponse,
|
|
10
|
+
EventId,
|
|
10
11
|
ExecutionStatus as JsonRpcExecutionStatus,
|
|
11
12
|
ObjectOwner,
|
|
12
13
|
SuiMoveAbilitySet,
|
|
@@ -19,6 +20,12 @@ import type {
|
|
|
19
20
|
SuiTransactionBlockResponse,
|
|
20
21
|
TransactionEffects,
|
|
21
22
|
} from './types/index.js';
|
|
23
|
+
import {
|
|
24
|
+
resolveEventFilter,
|
|
25
|
+
resolvePagination,
|
|
26
|
+
resolveTransactionFilter,
|
|
27
|
+
validateTransactionQuery,
|
|
28
|
+
} from '../client/query-filters.js';
|
|
22
29
|
import { Transaction } from '../transactions/Transaction.js';
|
|
23
30
|
import { computeGasBudget, coreClientResolveTransactionPlugin } from '../client/core-resolver.js';
|
|
24
31
|
import { TransactionDataBuilder } from '../transactions/TransactionData.js';
|
|
@@ -650,6 +657,118 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
650
657
|
};
|
|
651
658
|
}
|
|
652
659
|
|
|
660
|
+
/**
|
|
661
|
+
* @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
|
|
662
|
+
* from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
|
|
663
|
+
*/
|
|
664
|
+
async listTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
665
|
+
options: SuiClientTypes.ListTransactionsOptions<Include>,
|
|
666
|
+
): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {
|
|
667
|
+
const filter = options.filter
|
|
668
|
+
? await resolveTransactionFilter(this.mvr, options.filter, options.signal)
|
|
669
|
+
: undefined;
|
|
670
|
+
|
|
671
|
+
// Transaction cursors are digests, and bounds are interpreted relative to the
|
|
672
|
+
// traversal direction
|
|
673
|
+
const pagination = resolvePagination(options);
|
|
674
|
+
const { descending, after, before } = pagination;
|
|
675
|
+
validateTransactionQuery(filter, pagination);
|
|
676
|
+
|
|
677
|
+
const page = await this.#jsonRpcClient.queryTransactionBlocks({
|
|
678
|
+
filter:
|
|
679
|
+
filter &&
|
|
680
|
+
(filter.$kind === 'sender'
|
|
681
|
+
? { FromAddress: filter.sender }
|
|
682
|
+
: {
|
|
683
|
+
MoveFunction: {
|
|
684
|
+
package: filter.package,
|
|
685
|
+
module: filter.module ?? null,
|
|
686
|
+
function: filter.function ?? null,
|
|
687
|
+
},
|
|
688
|
+
}),
|
|
689
|
+
cursor: after ?? before,
|
|
690
|
+
limit: pagination.limit,
|
|
691
|
+
order: descending ? 'descending' : 'ascending',
|
|
692
|
+
options: {
|
|
693
|
+
// showRawInput is always needed to extract signatures from SenderSignedData
|
|
694
|
+
showRawInput: true,
|
|
695
|
+
// showEffects is always needed to get status
|
|
696
|
+
showEffects: true,
|
|
697
|
+
showObjectChanges: options.include?.objectTypes ?? false,
|
|
698
|
+
showRawEffects: options.include?.effects ?? false,
|
|
699
|
+
showEvents: options.include?.events ?? false,
|
|
700
|
+
showBalanceChanges: options.include?.balanceChanges ?? false,
|
|
701
|
+
},
|
|
702
|
+
signal: options.signal,
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
return {
|
|
706
|
+
transactions: page.data.map((transaction) => parseTransaction(transaction, options.include)),
|
|
707
|
+
hasNextPage: page.hasNextPage,
|
|
708
|
+
startCursor: page.data[0]?.digest ?? null,
|
|
709
|
+
endCursor: page.data.length
|
|
710
|
+
? (page.nextCursor ?? page.data[page.data.length - 1].digest)
|
|
711
|
+
: null,
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
|
|
717
|
+
* from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
|
|
718
|
+
*/
|
|
719
|
+
async listEvents(
|
|
720
|
+
options: SuiClientTypes.ListEventsOptions,
|
|
721
|
+
): Promise<SuiClientTypes.ListEventsResponse> {
|
|
722
|
+
const filter = options.filter
|
|
723
|
+
? await resolveEventFilter(this.mvr, options.filter, options.signal)
|
|
724
|
+
: undefined;
|
|
725
|
+
// Event cursors are event ids, and bounds are interpreted relative to the
|
|
726
|
+
// traversal direction
|
|
727
|
+
const { descending, after, before, limit } = resolvePagination(options);
|
|
728
|
+
const cursor = after ?? before;
|
|
729
|
+
|
|
730
|
+
const page = await this.#jsonRpcClient.queryEvents({
|
|
731
|
+
query: !filter
|
|
732
|
+
? { All: [] }
|
|
733
|
+
: filter.$kind === 'sender'
|
|
734
|
+
? { Sender: filter.sender }
|
|
735
|
+
: filter.$kind === 'emitModule'
|
|
736
|
+
? { MoveModule: { package: filter.package, module: filter.module } }
|
|
737
|
+
: filter.$kind === 'eventTypeModule'
|
|
738
|
+
? { MoveEventModule: { package: filter.package, module: filter.module } }
|
|
739
|
+
: { MoveEventType: filter.eventType },
|
|
740
|
+
cursor: cursor ? parseEventCursor(cursor) : undefined,
|
|
741
|
+
limit,
|
|
742
|
+
order: descending ? 'descending' : 'ascending',
|
|
743
|
+
signal: options.signal,
|
|
744
|
+
});
|
|
745
|
+
|
|
746
|
+
return {
|
|
747
|
+
events: page.data.map(
|
|
748
|
+
(event): SuiClientTypes.EventEntry => ({
|
|
749
|
+
packageId: normalizeSuiAddress(event.packageId),
|
|
750
|
+
module: event.transactionModule,
|
|
751
|
+
sender: normalizeSuiAddress(event.sender),
|
|
752
|
+
eventType: normalizeStructTag(event.type),
|
|
753
|
+
bcs: event.bcsEncoding === 'base58' ? fromBase58(event.bcs) : fromBase64(event.bcs),
|
|
754
|
+
json: (event.parsedJson as Record<string, unknown>) ?? null,
|
|
755
|
+
// queryEvents responses do not include checkpoint information
|
|
756
|
+
checkpoint: null,
|
|
757
|
+
transactionDigest: event.id.txDigest,
|
|
758
|
+
eventIndex: Number(event.id.eventSeq),
|
|
759
|
+
}),
|
|
760
|
+
),
|
|
761
|
+
hasNextPage: page.hasNextPage,
|
|
762
|
+
startCursor: page.data.length ? JSON.stringify(page.data[0].id) : null,
|
|
763
|
+
endCursor:
|
|
764
|
+
page.data.length && page.nextCursor
|
|
765
|
+
? JSON.stringify(page.nextCursor)
|
|
766
|
+
: page.data.length
|
|
767
|
+
? JSON.stringify(page.data[page.data.length - 1].id)
|
|
768
|
+
: null,
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
|
|
653
772
|
/**
|
|
654
773
|
* @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
|
|
655
774
|
* from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
|
|
@@ -948,6 +1067,18 @@ function parseOwnerAddress(owner: ObjectOwner): string | null {
|
|
|
948
1067
|
throw new Error(`Unknown owner type: ${JSON.stringify(owner)}`);
|
|
949
1068
|
}
|
|
950
1069
|
|
|
1070
|
+
function parseEventCursor(cursor: string): EventId {
|
|
1071
|
+
try {
|
|
1072
|
+
const parsed = JSON.parse(cursor) as EventId;
|
|
1073
|
+
if (typeof parsed?.txDigest !== 'string' || typeof parsed?.eventSeq !== 'string') {
|
|
1074
|
+
throw new Error('malformed event cursor');
|
|
1075
|
+
}
|
|
1076
|
+
return parsed;
|
|
1077
|
+
} catch {
|
|
1078
|
+
throw new Error(`Invalid event cursor: ${cursor}`);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
951
1082
|
function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
952
1083
|
transaction: SuiTransactionBlockResponse,
|
|
953
1084
|
include?: Include,
|
|
@@ -968,7 +1099,10 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
|
|
|
968
1099
|
|
|
969
1100
|
if (transaction.rawTransaction) {
|
|
970
1101
|
const parsedTx = bcs.SenderSignedData.parse(fromBase64(transaction.rawTransaction))[0];
|
|
971
|
-
|
|
1102
|
+
// The genesis transaction's raw data carries a placeholder signature that
|
|
1103
|
+
// other transports do not report
|
|
1104
|
+
signatures =
|
|
1105
|
+
parsedTx.intentMessage.value.V1.kind.$kind === 'Genesis' ? [] : parsedTx.txSignatures;
|
|
972
1106
|
|
|
973
1107
|
if (include?.transaction || include?.bcs) {
|
|
974
1108
|
const bytes = bcs.TransactionData.serialize(parsedTx.intentMessage.value).toBytes();
|
|
@@ -210,7 +210,6 @@ export async function resolveCoinBalance(
|
|
|
210
210
|
: null,
|
|
211
211
|
]);
|
|
212
212
|
|
|
213
|
-
const mergedCoins = new Map<string, Argument>();
|
|
214
213
|
const exactBalanceByType = new Map<string, boolean>();
|
|
215
214
|
const usedAddressBalance = new Set<string>();
|
|
216
215
|
|
|
@@ -351,8 +350,6 @@ export async function resolveCoinBalance(
|
|
|
351
350
|
commands.push(TransactionCommands.MergeCoins(baseCoin, rest.slice(i, i + 500)));
|
|
352
351
|
}
|
|
353
352
|
|
|
354
|
-
mergedCoins.set(type, baseCoin);
|
|
355
|
-
|
|
356
353
|
// Step 2: Combined SplitCoins for all intents of this type
|
|
357
354
|
const splitCmdIndex = index + commands.length;
|
|
358
355
|
commands.push(
|
|
@@ -389,6 +386,47 @@ export async function resolveCoinBalance(
|
|
|
389
386
|
}
|
|
390
387
|
}
|
|
391
388
|
|
|
389
|
+
// Step 3: Remainder handling
|
|
390
|
+
//
|
|
391
|
+
// Add cleanup to this replacement command list rather than appending
|
|
392
|
+
// it to the complete transaction. Appending cleanup can place it after
|
|
393
|
+
// a MoveCall that consumes Random, which Sui rejects.
|
|
394
|
+
//
|
|
395
|
+
// When gas type used GasCoin (not AB), leftover stays in the gas coin
|
|
396
|
+
// -- no remainder handling is needed.
|
|
397
|
+
if (type !== 'gas' || usedAddressBalance.has(type)) {
|
|
398
|
+
const hasBalanceIntent = intents.some((intent) => intent.outputKind === 'balance');
|
|
399
|
+
const sourcedFromAB = usedAddressBalance.has(type);
|
|
400
|
+
|
|
401
|
+
if (hasBalanceIntent || sourcedFromAB) {
|
|
402
|
+
// Sourced from AB or balance intents exist: send remainder back to sender's address
|
|
403
|
+
// balance. `coin::send_funds` is gasless-eligible and handles zero amounts.
|
|
404
|
+
commands.push(
|
|
405
|
+
TransactionCommands.MoveCall({
|
|
406
|
+
target: '0x2::coin::send_funds',
|
|
407
|
+
typeArguments: [coinType],
|
|
408
|
+
arguments: [
|
|
409
|
+
baseCoin,
|
|
410
|
+
transactionData.addInput(
|
|
411
|
+
'pure',
|
|
412
|
+
Inputs.Pure(bcs.Address.serialize(transactionData.sender!)),
|
|
413
|
+
),
|
|
414
|
+
],
|
|
415
|
+
}),
|
|
416
|
+
);
|
|
417
|
+
} else if (exactBalanceByType.get(type)) {
|
|
418
|
+
// Coin-only with exact match: destroy the zero-value dust coin.
|
|
419
|
+
commands.push(
|
|
420
|
+
TransactionCommands.MoveCall({
|
|
421
|
+
target: '0x2::coin::destroy_zero',
|
|
422
|
+
typeArguments: [coinType],
|
|
423
|
+
arguments: [baseCoin],
|
|
424
|
+
}),
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
// Coin-only with surplus: merged coin stays with sender as an owned object.
|
|
428
|
+
}
|
|
429
|
+
|
|
392
430
|
typeState.set(type, { results, nextIntent: 0 });
|
|
393
431
|
}
|
|
394
432
|
|
|
@@ -408,44 +446,6 @@ export async function resolveCoinBalance(
|
|
|
408
446
|
index += commands.length;
|
|
409
447
|
}
|
|
410
448
|
|
|
411
|
-
// Step 3: Remainder handling
|
|
412
|
-
for (const [type, mergedCoin] of mergedCoins) {
|
|
413
|
-
// When gas type used GasCoin (not AB), leftover stays in the gas coin — no remainder needed.
|
|
414
|
-
if (type === 'gas' && !usedAddressBalance.has(type)) continue;
|
|
415
|
-
|
|
416
|
-
const coinType = type === 'gas' ? SUI_TYPE : type;
|
|
417
|
-
const hasBalanceIntent = intentsByType.get(type)?.some((i) => i.outputKind === 'balance');
|
|
418
|
-
const sourcedFromAB = usedAddressBalance.has(type);
|
|
419
|
-
|
|
420
|
-
if (hasBalanceIntent || sourcedFromAB) {
|
|
421
|
-
// Sourced from AB or balance intents exist: send remainder back to sender's address balance.
|
|
422
|
-
// coin::send_funds is gasless-eligible and handles zero amounts.
|
|
423
|
-
transactionData.commands.push(
|
|
424
|
-
TransactionCommands.MoveCall({
|
|
425
|
-
target: '0x2::coin::send_funds',
|
|
426
|
-
typeArguments: [coinType],
|
|
427
|
-
arguments: [
|
|
428
|
-
mergedCoin,
|
|
429
|
-
transactionData.addInput(
|
|
430
|
-
'pure',
|
|
431
|
-
Inputs.Pure(bcs.Address.serialize(transactionData.sender!)),
|
|
432
|
-
),
|
|
433
|
-
],
|
|
434
|
-
}),
|
|
435
|
-
);
|
|
436
|
-
} else if (exactBalanceByType.get(type)) {
|
|
437
|
-
// Coin-only with exact match: destroy the zero-value dust coin.
|
|
438
|
-
transactionData.commands.push(
|
|
439
|
-
TransactionCommands.MoveCall({
|
|
440
|
-
target: '0x2::coin::destroy_zero',
|
|
441
|
-
typeArguments: [coinType],
|
|
442
|
-
arguments: [mergedCoin],
|
|
443
|
-
}),
|
|
444
|
-
);
|
|
445
|
-
}
|
|
446
|
-
// Coin-only with surplus: merged coin stays with sender as an owned object
|
|
447
|
-
}
|
|
448
|
-
|
|
449
449
|
return next();
|
|
450
450
|
}
|
|
451
451
|
|
package/src/version.ts
CHANGED
package/src/zklogin/address.ts
CHANGED
|
@@ -40,8 +40,8 @@ export function computeZkLoginAddressFromSeed(
|
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export const MAX_HEADER_LEN_B64 =
|
|
44
|
-
export const MAX_PADDED_UNSIGNED_JWT_LEN = 64 *
|
|
43
|
+
export const MAX_HEADER_LEN_B64 = 279;
|
|
44
|
+
export const MAX_PADDED_UNSIGNED_JWT_LEN = 64 * 30;
|
|
45
45
|
|
|
46
46
|
export function lengthChecks(jwt: string) {
|
|
47
47
|
const [header, payload] = jwt.split('.');
|
package/src/zklogin/poseidon.ts
CHANGED
|
@@ -54,10 +54,12 @@ export function poseidonHash(inputs: (number | bigint | string)[]): bigint {
|
|
|
54
54
|
|
|
55
55
|
if (hashFN) {
|
|
56
56
|
return hashFN(inputs);
|
|
57
|
-
} else if (inputs.length <=
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
} else if (inputs.length > 16 && inputs.length <= 64) {
|
|
58
|
+
const chunkHashes = [];
|
|
59
|
+
for (let i = 0; i < inputs.length; i += 16) {
|
|
60
|
+
chunkHashes.push(poseidonHash(inputs.slice(i, i + 16)));
|
|
61
|
+
}
|
|
62
|
+
return poseidonHash(chunkHashes);
|
|
61
63
|
} else {
|
|
62
64
|
throw new Error(`Yet to implement: Unable to hash a vector of length ${inputs.length}`);
|
|
63
65
|
}
|