@mysten/sui 2.31.3 → 2.32.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/CHANGELOG.md +9 -0
- package/dist/bcs/index.d.mts +36 -36
- package/dist/client/protocol-version.mjs +12 -0
- package/dist/client/protocol-version.mjs.map +1 -0
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +7 -4
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +2 -2
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/ledger_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/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
- package/dist/grpc/transport.d.mts +5 -3
- package/dist/grpc/transport.d.mts.map +1 -1
- package/dist/grpc/transport.mjs +32 -2
- package/dist/grpc/transport.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +3 -3
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/docs/clients/grpc.md +7 -1
- package/package.json +1 -1
- package/src/client/protocol-version.ts +11 -0
- package/src/graphql/client.ts +13 -4
- package/src/grpc/client.ts +5 -3
- package/src/grpc/transport.ts +40 -1
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mysten/sui.js
|
|
2
2
|
|
|
3
|
+
## 2.32.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4394023: `SuiGrpcClient`, `GrpcWebFetchTransport`, and `SuiGraphQLClient` now send an
|
|
8
|
+
`x-sui-client-protocol-version` header with the highest protocol version whose types the SDK can
|
|
9
|
+
decode. `SuiGrpcClient` adds the header for custom transports too, including native gRPC, while
|
|
10
|
+
preserving explicit transport and per-call metadata overrides.
|
|
11
|
+
|
|
3
12
|
## 2.31.3
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/bcs/index.d.mts
CHANGED
|
@@ -549,7 +549,7 @@ declare const suiBcs: {
|
|
|
549
549
|
version: string;
|
|
550
550
|
digest: string;
|
|
551
551
|
};
|
|
552
|
-
}, "
|
|
552
|
+
}, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
|
|
553
553
|
FundsWithdrawal: {
|
|
554
554
|
reservation: {
|
|
555
555
|
MaxAmountU64: string;
|
|
@@ -568,7 +568,7 @@ declare const suiBcs: {
|
|
|
568
568
|
};
|
|
569
569
|
}, "Sender" | "Sponsor" | "SenderAllowance">;
|
|
570
570
|
};
|
|
571
|
-
}, "
|
|
571
|
+
}, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
572
572
|
Pure: {
|
|
573
573
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
574
574
|
};
|
|
@@ -805,7 +805,7 @@ declare const suiBcs: {
|
|
|
805
805
|
TransactionEffects: true;
|
|
806
806
|
CheckpointSummary: true;
|
|
807
807
|
PersonalMessage: true;
|
|
808
|
-
}, "
|
|
808
|
+
}, "TransactionEffects" | "TransactionData" | "CheckpointSummary" | "PersonalMessage">;
|
|
809
809
|
version: {
|
|
810
810
|
V0: true;
|
|
811
811
|
$kind: "V0";
|
|
@@ -839,7 +839,7 @@ declare const suiBcs: {
|
|
|
839
839
|
version: string;
|
|
840
840
|
digest: string;
|
|
841
841
|
};
|
|
842
|
-
}, "
|
|
842
|
+
}, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
|
|
843
843
|
FundsWithdrawal: {
|
|
844
844
|
reservation: {
|
|
845
845
|
MaxAmountU64: string;
|
|
@@ -858,7 +858,7 @@ declare const suiBcs: {
|
|
|
858
858
|
};
|
|
859
859
|
}, "Sender" | "Sponsor" | "SenderAllowance">;
|
|
860
860
|
};
|
|
861
|
-
}, "
|
|
861
|
+
}, "Object" | "Pure" | "FundsWithdrawal">[];
|
|
862
862
|
commands: _mysten_bcs0.EnumOutputShapeWithKeys<{
|
|
863
863
|
MoveCall: {
|
|
864
864
|
package: string;
|
|
@@ -997,7 +997,7 @@ declare const suiBcs: {
|
|
|
997
997
|
startVersion: string;
|
|
998
998
|
owner: string;
|
|
999
999
|
};
|
|
1000
|
-
}, "AddressOwner" | "
|
|
1000
|
+
}, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">;
|
|
1001
1001
|
};
|
|
1002
1002
|
$kind: "RawObject";
|
|
1003
1003
|
}[];
|
|
@@ -1130,7 +1130,7 @@ declare const suiBcs: {
|
|
|
1130
1130
|
version: string;
|
|
1131
1131
|
digest: string;
|
|
1132
1132
|
};
|
|
1133
|
-
}, "
|
|
1133
|
+
}, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
|
|
1134
1134
|
FundsWithdrawal: {
|
|
1135
1135
|
reservation: {
|
|
1136
1136
|
MaxAmountU64: string;
|
|
@@ -1149,7 +1149,7 @@ declare const suiBcs: {
|
|
|
1149
1149
|
};
|
|
1150
1150
|
}, "Sender" | "Sponsor" | "SenderAllowance">;
|
|
1151
1151
|
};
|
|
1152
|
-
}, "
|
|
1152
|
+
}, "Object" | "Pure" | "FundsWithdrawal">[];
|
|
1153
1153
|
commands: _mysten_bcs0.EnumOutputShapeWithKeys<{
|
|
1154
1154
|
MoveCall: {
|
|
1155
1155
|
package: string;
|
|
@@ -1231,7 +1231,7 @@ declare const suiBcs: {
|
|
|
1231
1231
|
};
|
|
1232
1232
|
}, "MoveCall" | "TransferObjects" | "SplitCoins" | "MergeCoins" | "Publish" | "MakeMoveVec" | "Upgrade">[];
|
|
1233
1233
|
};
|
|
1234
|
-
}, "
|
|
1234
|
+
}, "EndOfEpochTransaction" | "ProgrammableSystemTransaction" | "ProgrammableTransaction" | "ChangeEpoch" | "Genesis" | "ConsensusCommitPrologue" | "AuthenticatorStateUpdate" | "RandomnessStateUpdate" | "ConsensusCommitPrologueV2" | "ConsensusCommitPrologueV3" | "ConsensusCommitPrologueV4">;
|
|
1235
1235
|
sender: string;
|
|
1236
1236
|
gasData: {
|
|
1237
1237
|
payment: {
|
|
@@ -1266,7 +1266,7 @@ declare const suiBcs: {
|
|
|
1266
1266
|
proposers: number[];
|
|
1267
1267
|
} | null;
|
|
1268
1268
|
};
|
|
1269
|
-
}, "
|
|
1269
|
+
}, "Epoch" | "None" | "ValidDuring" | "Validity">;
|
|
1270
1270
|
};
|
|
1271
1271
|
$kind: "V1";
|
|
1272
1272
|
};
|
|
@@ -1877,7 +1877,7 @@ declare const suiBcs: {
|
|
|
1877
1877
|
version: string;
|
|
1878
1878
|
digest: string;
|
|
1879
1879
|
};
|
|
1880
|
-
}, "
|
|
1880
|
+
}, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
|
|
1881
1881
|
FundsWithdrawal: {
|
|
1882
1882
|
reservation: {
|
|
1883
1883
|
MaxAmountU64: string;
|
|
@@ -1896,7 +1896,7 @@ declare const suiBcs: {
|
|
|
1896
1896
|
};
|
|
1897
1897
|
}, "Sender" | "Sponsor" | "SenderAllowance">;
|
|
1898
1898
|
};
|
|
1899
|
-
}, "
|
|
1899
|
+
}, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
1900
1900
|
Pure: {
|
|
1901
1901
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
1902
1902
|
};
|
|
@@ -2181,7 +2181,7 @@ declare const suiBcs: {
|
|
|
2181
2181
|
startVersion: string;
|
|
2182
2182
|
owner: string;
|
|
2183
2183
|
};
|
|
2184
|
-
}, "AddressOwner" | "
|
|
2184
|
+
}, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">;
|
|
2185
2185
|
};
|
|
2186
2186
|
$kind: "RawObject";
|
|
2187
2187
|
}[], Iterable<{
|
|
@@ -2459,7 +2459,7 @@ declare const suiBcs: {
|
|
|
2459
2459
|
version: string;
|
|
2460
2460
|
digest: string;
|
|
2461
2461
|
};
|
|
2462
|
-
}, "
|
|
2462
|
+
}, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
|
|
2463
2463
|
FundsWithdrawal: {
|
|
2464
2464
|
reservation: {
|
|
2465
2465
|
MaxAmountU64: string;
|
|
@@ -2478,7 +2478,7 @@ declare const suiBcs: {
|
|
|
2478
2478
|
};
|
|
2479
2479
|
}, "Sender" | "Sponsor" | "SenderAllowance">;
|
|
2480
2480
|
};
|
|
2481
|
-
}, "
|
|
2481
|
+
}, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
2482
2482
|
Pure: {
|
|
2483
2483
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
2484
2484
|
};
|
|
@@ -2794,7 +2794,7 @@ declare const suiBcs: {
|
|
|
2794
2794
|
version: string;
|
|
2795
2795
|
digest: string;
|
|
2796
2796
|
};
|
|
2797
|
-
}, "
|
|
2797
|
+
}, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
|
|
2798
2798
|
FundsWithdrawal: {
|
|
2799
2799
|
reservation: {
|
|
2800
2800
|
MaxAmountU64: string;
|
|
@@ -2813,7 +2813,7 @@ declare const suiBcs: {
|
|
|
2813
2813
|
};
|
|
2814
2814
|
}, "Sender" | "Sponsor" | "SenderAllowance">;
|
|
2815
2815
|
};
|
|
2816
|
-
}, "
|
|
2816
|
+
}, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
2817
2817
|
Pure: {
|
|
2818
2818
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
2819
2819
|
};
|
|
@@ -3098,7 +3098,7 @@ declare const suiBcs: {
|
|
|
3098
3098
|
startVersion: string;
|
|
3099
3099
|
owner: string;
|
|
3100
3100
|
};
|
|
3101
|
-
}, "AddressOwner" | "
|
|
3101
|
+
}, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">;
|
|
3102
3102
|
};
|
|
3103
3103
|
$kind: "RawObject";
|
|
3104
3104
|
}[], Iterable<{
|
|
@@ -3376,7 +3376,7 @@ declare const suiBcs: {
|
|
|
3376
3376
|
version: string;
|
|
3377
3377
|
digest: string;
|
|
3378
3378
|
};
|
|
3379
|
-
}, "
|
|
3379
|
+
}, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
|
|
3380
3380
|
FundsWithdrawal: {
|
|
3381
3381
|
reservation: {
|
|
3382
3382
|
MaxAmountU64: string;
|
|
@@ -3395,7 +3395,7 @@ declare const suiBcs: {
|
|
|
3395
3395
|
};
|
|
3396
3396
|
}, "Sender" | "Sponsor" | "SenderAllowance">;
|
|
3397
3397
|
};
|
|
3398
|
-
}, "
|
|
3398
|
+
}, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
3399
3399
|
Pure: {
|
|
3400
3400
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
3401
3401
|
};
|
|
@@ -3687,7 +3687,7 @@ declare const suiBcs: {
|
|
|
3687
3687
|
version: string;
|
|
3688
3688
|
digest: string;
|
|
3689
3689
|
};
|
|
3690
|
-
}, "
|
|
3690
|
+
}, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
|
|
3691
3691
|
FundsWithdrawal: {
|
|
3692
3692
|
reservation: {
|
|
3693
3693
|
MaxAmountU64: string;
|
|
@@ -3706,7 +3706,7 @@ declare const suiBcs: {
|
|
|
3706
3706
|
};
|
|
3707
3707
|
}, "Sender" | "Sponsor" | "SenderAllowance">;
|
|
3708
3708
|
};
|
|
3709
|
-
}, "
|
|
3709
|
+
}, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
3710
3710
|
Pure: {
|
|
3711
3711
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
3712
3712
|
};
|
|
@@ -3991,7 +3991,7 @@ declare const suiBcs: {
|
|
|
3991
3991
|
startVersion: string;
|
|
3992
3992
|
owner: string;
|
|
3993
3993
|
};
|
|
3994
|
-
}, "AddressOwner" | "
|
|
3994
|
+
}, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">;
|
|
3995
3995
|
};
|
|
3996
3996
|
$kind: "RawObject";
|
|
3997
3997
|
}[], Iterable<{
|
|
@@ -4269,7 +4269,7 @@ declare const suiBcs: {
|
|
|
4269
4269
|
version: string;
|
|
4270
4270
|
digest: string;
|
|
4271
4271
|
};
|
|
4272
|
-
}, "
|
|
4272
|
+
}, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
|
|
4273
4273
|
FundsWithdrawal: {
|
|
4274
4274
|
reservation: {
|
|
4275
4275
|
MaxAmountU64: string;
|
|
@@ -4288,7 +4288,7 @@ declare const suiBcs: {
|
|
|
4288
4288
|
};
|
|
4289
4289
|
}, "Sender" | "Sponsor" | "SenderAllowance">;
|
|
4290
4290
|
};
|
|
4291
|
-
}, "
|
|
4291
|
+
}, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
4292
4292
|
Pure: {
|
|
4293
4293
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
4294
4294
|
};
|
|
@@ -4762,7 +4762,7 @@ declare const suiBcs: {
|
|
|
4762
4762
|
startVersion: string;
|
|
4763
4763
|
owner: string;
|
|
4764
4764
|
};
|
|
4765
|
-
}, "AddressOwner" | "
|
|
4765
|
+
}, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">][], Iterable<readonly [{
|
|
4766
4766
|
objectId: string | Uint8Array<ArrayBufferLike>;
|
|
4767
4767
|
version: string | number | bigint;
|
|
4768
4768
|
digest: string;
|
|
@@ -4795,7 +4795,7 @@ declare const suiBcs: {
|
|
|
4795
4795
|
startVersion: string;
|
|
4796
4796
|
owner: string;
|
|
4797
4797
|
};
|
|
4798
|
-
}, "AddressOwner" | "
|
|
4798
|
+
}, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">][], Iterable<readonly [{
|
|
4799
4799
|
objectId: string | Uint8Array<ArrayBufferLike>;
|
|
4800
4800
|
version: string | number | bigint;
|
|
4801
4801
|
digest: string;
|
|
@@ -4828,7 +4828,7 @@ declare const suiBcs: {
|
|
|
4828
4828
|
startVersion: string;
|
|
4829
4829
|
owner: string;
|
|
4830
4830
|
};
|
|
4831
|
-
}, "AddressOwner" | "
|
|
4831
|
+
}, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">][], Iterable<readonly [{
|
|
4832
4832
|
objectId: string | Uint8Array<ArrayBufferLike>;
|
|
4833
4833
|
version: string | number | bigint;
|
|
4834
4834
|
digest: string;
|
|
@@ -5096,7 +5096,7 @@ declare const suiBcs: {
|
|
|
5096
5096
|
startVersion: string;
|
|
5097
5097
|
owner: string;
|
|
5098
5098
|
};
|
|
5099
|
-
}, "AddressOwner" | "
|
|
5099
|
+
}, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">];
|
|
5100
5100
|
}, "NotExist" | "Exist">;
|
|
5101
5101
|
outputState: _mysten_bcs0.EnumOutputShapeWithKeys<{
|
|
5102
5102
|
NotExist: true;
|
|
@@ -5111,7 +5111,7 @@ declare const suiBcs: {
|
|
|
5111
5111
|
startVersion: string;
|
|
5112
5112
|
owner: string;
|
|
5113
5113
|
};
|
|
5114
|
-
}, "AddressOwner" | "
|
|
5114
|
+
}, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">];
|
|
5115
5115
|
PackageWrite: [string, string];
|
|
5116
5116
|
AccumulatorWriteV1: {
|
|
5117
5117
|
address: {
|
|
@@ -5197,7 +5197,7 @@ declare const suiBcs: {
|
|
|
5197
5197
|
ReadConsensusStreamEnded: string;
|
|
5198
5198
|
Cancelled: string;
|
|
5199
5199
|
PerEpochConfig: true;
|
|
5200
|
-
}, "
|
|
5200
|
+
}, "MutateConsensusStreamEnded" | "PerEpochConfig" | "ReadConsensusStreamEnded" | "ReadOnlyRoot" | "Cancelled">][], Iterable<readonly [string | Uint8Array<ArrayBufferLike>, _mysten_bcs0.EnumInputShape<{
|
|
5201
5201
|
ReadOnlyRoot: readonly [string | number | bigint, string];
|
|
5202
5202
|
MutateConsensusStreamEnded: string | number | bigint;
|
|
5203
5203
|
ReadConsensusStreamEnded: string | number | bigint;
|
|
@@ -5258,7 +5258,7 @@ declare const suiBcs: {
|
|
|
5258
5258
|
version: string;
|
|
5259
5259
|
digest: string;
|
|
5260
5260
|
};
|
|
5261
|
-
}, "
|
|
5261
|
+
}, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
|
|
5262
5262
|
FundsWithdrawal: {
|
|
5263
5263
|
reservation: {
|
|
5264
5264
|
MaxAmountU64: string;
|
|
@@ -5277,7 +5277,7 @@ declare const suiBcs: {
|
|
|
5277
5277
|
};
|
|
5278
5278
|
}, "Sender" | "Sponsor" | "SenderAllowance">;
|
|
5279
5279
|
};
|
|
5280
|
-
}, "
|
|
5280
|
+
}, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
5281
5281
|
Pure: {
|
|
5282
5282
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
5283
5283
|
};
|
|
@@ -5562,7 +5562,7 @@ declare const suiBcs: {
|
|
|
5562
5562
|
startVersion: string;
|
|
5563
5563
|
owner: string;
|
|
5564
5564
|
};
|
|
5565
|
-
}, "AddressOwner" | "
|
|
5565
|
+
}, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">;
|
|
5566
5566
|
};
|
|
5567
5567
|
$kind: "RawObject";
|
|
5568
5568
|
}[], Iterable<{
|
|
@@ -5840,7 +5840,7 @@ declare const suiBcs: {
|
|
|
5840
5840
|
version: string;
|
|
5841
5841
|
digest: string;
|
|
5842
5842
|
};
|
|
5843
|
-
}, "
|
|
5843
|
+
}, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
|
|
5844
5844
|
FundsWithdrawal: {
|
|
5845
5845
|
reservation: {
|
|
5846
5846
|
MaxAmountU64: string;
|
|
@@ -5859,7 +5859,7 @@ declare const suiBcs: {
|
|
|
5859
5859
|
};
|
|
5860
5860
|
}, "Sender" | "Sponsor" | "SenderAllowance">;
|
|
5861
5861
|
};
|
|
5862
|
-
}, "
|
|
5862
|
+
}, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
5863
5863
|
Pure: {
|
|
5864
5864
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
5865
5865
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/client/protocol-version.ts
|
|
2
|
+
/** Request header carrying the highest protocol version whose types the client can decode. */
|
|
3
|
+
const CLIENT_PROTOCOL_VERSION_HEADER = "x-sui-client-protocol-version";
|
|
4
|
+
/**
|
|
5
|
+
* Highest Sui protocol version whose on-chain types this SDK can decode. Bump this when the SDK
|
|
6
|
+
* gains support for types introduced in a newer protocol version.
|
|
7
|
+
*/
|
|
8
|
+
const MAX_PROTOCOL_VERSION = 138;
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { CLIENT_PROTOCOL_VERSION_HEADER, MAX_PROTOCOL_VERSION };
|
|
12
|
+
//# sourceMappingURL=protocol-version.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-version.mjs","names":[],"sources":["../../src/client/protocol-version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n/** Request header carrying the highest protocol version whose types the client can decode. */\nexport const CLIENT_PROTOCOL_VERSION_HEADER = 'x-sui-client-protocol-version';\n\n/**\n * Highest Sui protocol version whose on-chain types this SDK can decode. Bump this when the SDK\n * gains support for types introduced in a newer protocol version.\n */\nexport const MAX_PROTOCOL_VERSION = 138;\n"],"mappings":";;AAIA,MAAa,iCAAiC;;;;;AAM9C,MAAa,uBAAuB"}
|
|
@@ -30,6 +30,12 @@ declare function parseSerializedSignature(serializedSignature: string): {
|
|
|
30
30
|
clientDataJson: string;
|
|
31
31
|
userSignature: Uint8Array<ArrayBuffer>;
|
|
32
32
|
publicKey: Uint8Array<ArrayBuffer>;
|
|
33
|
+
} | {
|
|
34
|
+
serializedSignature: string;
|
|
35
|
+
signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
|
|
36
|
+
signature: Uint8Array<ArrayBuffer>;
|
|
37
|
+
publicKey: Uint8Array<ArrayBuffer>;
|
|
38
|
+
bytes: Uint8Array<ArrayBuffer>;
|
|
33
39
|
} | {
|
|
34
40
|
serializedSignature: string;
|
|
35
41
|
signatureScheme: "ZkLogin";
|
|
@@ -54,12 +60,6 @@ declare function parseSerializedSignature(serializedSignature: string): {
|
|
|
54
60
|
};
|
|
55
61
|
signature: Uint8Array<ArrayBufferLike>;
|
|
56
62
|
publicKey: Uint8Array<ArrayBuffer>;
|
|
57
|
-
} | {
|
|
58
|
-
serializedSignature: string;
|
|
59
|
-
signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
|
|
60
|
-
signature: Uint8Array<ArrayBuffer>;
|
|
61
|
-
publicKey: Uint8Array<ArrayBuffer>;
|
|
62
|
-
bytes: Uint8Array<ArrayBuffer>;
|
|
63
63
|
} | {
|
|
64
64
|
serializedSignature: string;
|
|
65
65
|
signatureScheme: "MultiSig";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","names":[],"sources":["../../src/graphql/client.ts"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3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O,cAAA,CAAe,6BAAA,GACpB,OAAA,CAAQ,cAAA,CAAe,8BAAA;EAI1B,yBAAA,CACC,KAAA,EAAO,cAAA,CAAe,gCAAA,GACpB,OAAA,CAAQ,cAAA,CAAe,iCAAA;AAAA"}
|
package/dist/graphql/client.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { normalizeStructTag } from "../utils/sui-types.mjs";
|
|
2
2
|
import { BaseClient } from "../client/client.mjs";
|
|
3
3
|
import { deriveDynamicFieldID } from "../utils/dynamic-fields.mjs";
|
|
4
|
+
import { CLIENT_PROTOCOL_VERSION_HEADER, MAX_PROTOCOL_VERSION } from "../client/protocol-version.mjs";
|
|
4
5
|
import { GetDynamicFieldsDocument } from "./generated/queries.mjs";
|
|
5
6
|
import { GraphQLCoreClient } from "./core.mjs";
|
|
6
7
|
import { fromBase64 } from "@mysten/utils";
|
|
@@ -35,12 +36,14 @@ var SuiGraphQLClient = class extends BaseClient {
|
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
async query(options) {
|
|
39
|
+
const headers = new Headers({
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
...this.#headers
|
|
42
|
+
});
|
|
43
|
+
if (!headers.has(CLIENT_PROTOCOL_VERSION_HEADER)) headers.set(CLIENT_PROTOCOL_VERSION_HEADER, String(MAX_PROTOCOL_VERSION));
|
|
38
44
|
const res = await this.#fetch(this.#url, {
|
|
39
45
|
method: "POST",
|
|
40
|
-
headers
|
|
41
|
-
"Content-Type": "application/json",
|
|
42
|
-
...this.#headers
|
|
43
|
-
},
|
|
46
|
+
headers,
|
|
44
47
|
body: JSON.stringify({
|
|
45
48
|
query: typeof options.query === "string" || options.query instanceof String ? String(options.query) : print(options.query),
|
|
46
49
|
variables: options.variables,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","names":["#url","#queries","#headers","#fetch"],"sources":["../../src/graphql/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport type { TadaDocumentNode } from 'gql.tada';\nimport type { DocumentNode } from 'graphql';\nimport { print } from 'graphql';\nimport { BaseClient } from '../client/index.js';\nimport type { SuiClientTypes } from '../client/index.js';\nimport { GraphQLCoreClient } from './core.js';\nimport type { TypedDocumentString } from './generated/queries.js';\nimport { GetDynamicFieldsDocument } from './generated/queries.js';\nimport { fromBase64 } from '@mysten/utils';\nimport { normalizeStructTag } from '../utils/sui-types.js';\nimport { deriveDynamicFieldID } from '../utils/dynamic-fields.js';\nimport type { TransactionPlugin } from '../transactions/index.js';\n\nexport type GraphQLDocument<Result = Record<string, unknown>, Variables = Record<string, unknown>> =\n\t| string\n\t| DocumentNode\n\t| TypedDocumentString<Result, Variables>\n\t| TypedDocumentNode<Result, Variables>\n\t| TadaDocumentNode<Result, Variables>;\n\nexport type GraphQLQueryOptions<\n\tResult = Record<string, unknown>,\n\tVariables = Record<string, unknown>,\n> = {\n\tquery: GraphQLDocument<Result, Variables>;\n\toperationName?: string;\n\textensions?: Record<string, unknown>;\n\tsignal?: AbortSignal;\n} & (Variables extends { [key: string]: never }\n\t? { variables?: Variables }\n\t: {\n\t\t\tvariables: Variables;\n\t\t});\n\nexport type GraphQLQueryResult<Result = Record<string, unknown>> = {\n\tdata?: Result;\n\terrors?: GraphQLResponseErrors;\n\textensions?: Record<string, unknown>;\n};\n\nexport type GraphQLResponseErrors = Array<{\n\tmessage: string;\n\tlocations?: { line: number; column: number }[];\n\tpath?: (string | number)[];\n}>;\n\nexport interface SuiGraphQLClientOptions<Queries extends Record<string, GraphQLDocument>> {\n\turl: string;\n\tfetch?: typeof fetch;\n\theaders?: Record<string, string>;\n\tqueries?: Queries;\n\tnetwork: SuiClientTypes.Network;\n\tmvr?: SuiClientTypes.MvrOptions;\n}\n\nexport class SuiGraphQLRequestError extends Error {}\n\nconst SUI_CLIENT_BRAND = Symbol.for('@mysten/SuiGraphQLClient') as never;\n\nexport function isSuiGraphQLClient(client: unknown): client is SuiGraphQLClient {\n\treturn (\n\t\ttypeof client === 'object' && client !== null && (client as any)[SUI_CLIENT_BRAND] === true\n\t);\n}\n\nexport interface GraphQLSimulateTransactionOptions<\n\tInclude extends SuiClientTypes.SimulateTransactionInclude = {},\n> extends SuiClientTypes.SimulateTransactionOptions<Include> {\n\t/**\n\t * Overrides whether the server selects gas payment during simulation.\n\t *\n\t * When not set, gas selection is enabled only when the transaction's gas payment is explicitly\n\t * set to an empty list (`[]`), which indicates gas is paid from the sender's address balance.\n\t * Transactions with gas coins set are simulated as-is, and transactions without a gas payment\n\t * are simulated with a mocked gas coin.\n\t */\n\tdoGasSelection?: boolean;\n}\n\nexport interface DynamicFieldInclude {\n\tvalue?: boolean;\n}\n\nexport type DynamicFieldEntryWithValue<Include extends DynamicFieldInclude = {}> =\n\tSuiClientTypes.DynamicFieldEntry & {\n\t\tvalue: Include extends { value: true } ? SuiClientTypes.DynamicFieldValue : undefined;\n\t};\n\nexport interface ListDynamicFieldsWithValueResponse<Include extends DynamicFieldInclude = {}> {\n\thasNextPage: boolean;\n\tcursor: string | null;\n\tdynamicFields: DynamicFieldEntryWithValue<Include>[];\n}\n\nexport class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> = {}>\n\textends BaseClient\n\timplements SuiClientTypes.TransportMethods\n{\n\t#url: string;\n\t#queries: Queries;\n\t#headers: Record<string, string>;\n\t#fetch: typeof fetch;\n\tcore: GraphQLCoreClient;\n\tget mvr(): SuiClientTypes.MvrMethods {\n\t\treturn this.core.mvr;\n\t}\n\n\tget [SUI_CLIENT_BRAND]() {\n\t\treturn true;\n\t}\n\n\tconstructor({\n\t\turl,\n\t\tfetch: fetchFn = fetch,\n\t\theaders = {},\n\t\tqueries = {} as Queries,\n\t\tnetwork,\n\t\tmvr,\n\t}: SuiGraphQLClientOptions<Queries>) {\n\t\tsuper({\n\t\t\tnetwork,\n\t\t});\n\t\tthis.#url = url;\n\t\tthis.#queries = queries;\n\t\tthis.#headers = headers;\n\t\tthis.#fetch = (...args) => fetchFn(...args);\n\t\tthis.core = new GraphQLCoreClient({\n\t\t\tgraphqlClient: this,\n\t\t\tmvr,\n\t\t});\n\t}\n\n\tasync query<Result = Record<string, unknown>, Variables = Record<string, unknown>>(\n\t\toptions: GraphQLQueryOptions<Result, Variables>,\n\t): Promise<GraphQLQueryResult<Result>> {\n\t\tconst res = await this.#fetch(this.#url, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t...this.#headers,\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tquery:\n\t\t\t\t\ttypeof options.query === 'string' || options.query instanceof String\n\t\t\t\t\t\t? String(options.query)\n\t\t\t\t\t\t: print(options.query),\n\t\t\t\tvariables: options.variables,\n\t\t\t\textensions: options.extensions,\n\t\t\t\toperationName: options.operationName,\n\t\t\t}),\n\t\t\tsignal: options.signal,\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new SuiGraphQLRequestError(`GraphQL request failed: ${res.statusText} (${res.status})`);\n\t\t}\n\n\t\treturn await res.json();\n\t}\n\n\tasync execute<\n\t\tconst Query extends Extract<keyof Queries, string>,\n\t\tResult = Queries[Query] extends GraphQLDocument<infer R, unknown> ? R : Record<string, unknown>,\n\t\tVariables = Queries[Query] extends GraphQLDocument<unknown, infer V>\n\t\t\t? V\n\t\t\t: Record<string, unknown>,\n\t>(\n\t\tquery: Query,\n\t\toptions: Omit<GraphQLQueryOptions<Result, Variables>, 'query'>,\n\t): Promise<GraphQLQueryResult<Result>> {\n\t\treturn this.query({\n\t\t\t...(options as { variables: Record<string, unknown> }),\n\t\t\tquery: this.#queries[query]!,\n\t\t}) as Promise<GraphQLQueryResult<Result>>;\n\t}\n\n\tgetObjects<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetObjectsOptions<Include>,\n\t): Promise<SuiClientTypes.GetObjectsResponse<Include>> {\n\t\treturn this.core.getObjects(input);\n\t}\n\n\tgetObject<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetObjectOptions<Include>,\n\t): Promise<SuiClientTypes.GetObjectResponse<Include>> {\n\t\treturn this.core.getObject(input);\n\t}\n\n\tlistCoins(input: SuiClientTypes.ListCoinsOptions): Promise<SuiClientTypes.ListCoinsResponse> {\n\t\treturn this.core.listCoins(input);\n\t}\n\n\tlistOwnedObjects<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.ListOwnedObjectsOptions<Include>,\n\t): Promise<SuiClientTypes.ListOwnedObjectsResponse<Include>> {\n\t\treturn this.core.listOwnedObjects(input);\n\t}\n\n\tgetBalance(input: SuiClientTypes.GetBalanceOptions): Promise<SuiClientTypes.GetBalanceResponse> {\n\t\treturn this.core.getBalance(input);\n\t}\n\n\tlistBalances(\n\t\tinput: SuiClientTypes.ListBalancesOptions,\n\t): Promise<SuiClientTypes.ListBalancesResponse> {\n\t\treturn this.core.listBalances(input);\n\t}\n\n\tgetCoinMetadata(\n\t\tinput: SuiClientTypes.GetCoinMetadataOptions,\n\t): Promise<SuiClientTypes.GetCoinMetadataResponse> {\n\t\treturn this.core.getCoinMetadata(input);\n\t}\n\n\tgetTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.GetTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.getTransaction(input);\n\t}\n\n\texecuteTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.ExecuteTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.executeTransaction(input);\n\t}\n\n\tsignAndExecuteTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.SignAndExecuteTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.signAndExecuteTransaction(input);\n\t}\n\n\twaitForTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.WaitForTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.waitForTransaction(input);\n\t}\n\n\tsimulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(\n\t\tinput: GraphQLSimulateTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {\n\t\treturn this.core.simulateTransaction(input);\n\t}\n\n\tgetReferenceGasPrice(\n\t\tinput?: SuiClientTypes.GetReferenceGasPriceOptions,\n\t): Promise<SuiClientTypes.GetReferenceGasPriceResponse> {\n\t\treturn this.core.getReferenceGasPrice(input);\n\t}\n\n\tgetCurrentSystemState(\n\t\tinput?: SuiClientTypes.GetCurrentSystemStateOptions,\n\t): Promise<SuiClientTypes.GetCurrentSystemStateResponse> {\n\t\treturn this.core.getCurrentSystemState(input);\n\t}\n\n\tgetProtocolConfig(\n\t\tinput?: SuiClientTypes.GetProtocolConfigOptions,\n\t): Promise<SuiClientTypes.GetProtocolConfigResponse> {\n\t\treturn this.core.getProtocolConfig(input);\n\t}\n\n\tgetChainIdentifier(\n\t\tinput?: SuiClientTypes.GetChainIdentifierOptions,\n\t): Promise<SuiClientTypes.GetChainIdentifierResponse> {\n\t\treturn this.core.getChainIdentifier(input);\n\t}\n\n\tasync listDynamicFields<Include extends DynamicFieldInclude = {}>(\n\t\tinput: SuiClientTypes.ListDynamicFieldsOptions & { include?: Include & DynamicFieldInclude },\n\t): Promise<ListDynamicFieldsWithValueResponse<Include>> {\n\t\tconst includeValue = input.include?.value ?? false;\n\n\t\tconst { data, errors } = await this.query({\n\t\t\tquery: GetDynamicFieldsDocument,\n\t\t\tsignal: input.signal,\n\t\t\tvariables: {\n\t\t\t\tparentId: input.parentId,\n\t\t\t\tfirst: input.limit,\n\t\t\t\tcursor: input.cursor,\n\t\t\t\tincludeValue,\n\t\t\t},\n\t\t});\n\n\t\tif (errors?.length) {\n\t\t\tthrow errors.length === 1\n\t\t\t\t? new Error(errors[0].message)\n\t\t\t\t: new AggregateError(errors.map((e) => new Error(e.message)));\n\t\t}\n\n\t\tconst result = data?.address?.dynamicFields;\n\t\tif (!result) {\n\t\t\tthrow new Error('Missing response data');\n\t\t}\n\n\t\treturn {\n\t\t\tdynamicFields: result.nodes.map((dynamicField): DynamicFieldEntryWithValue<Include> => {\n\t\t\t\tconst valueType =\n\t\t\t\t\tdynamicField.value?.__typename === 'MoveObject'\n\t\t\t\t\t\t? dynamicField.value.contents?.type?.repr!\n\t\t\t\t\t\t: dynamicField.value?.type?.repr!;\n\t\t\t\tconst isDynamicObject = dynamicField.value?.__typename === 'MoveObject';\n\t\t\t\tconst derivedNameType = isDynamicObject\n\t\t\t\t\t? `0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type?.repr}>`\n\t\t\t\t\t: dynamicField.name?.type?.repr!;\n\n\t\t\t\tlet value: SuiClientTypes.DynamicFieldValue | undefined;\n\t\t\t\tif (includeValue) {\n\t\t\t\t\tlet valueBcs: Uint8Array;\n\t\t\t\t\tif (dynamicField.value?.__typename === 'MoveValue') {\n\t\t\t\t\t\tvalueBcs = fromBase64(dynamicField.value.bcs ?? '');\n\t\t\t\t\t} else if (dynamicField.value?.__typename === 'MoveObject') {\n\t\t\t\t\t\tvalueBcs = fromBase64(dynamicField.value.contents?.bcs ?? '');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalueBcs = new Uint8Array();\n\t\t\t\t\t}\n\t\t\t\t\tvalue = { type: valueType, bcs: valueBcs };\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',\n\t\t\t\t\tfieldId: deriveDynamicFieldID(\n\t\t\t\t\t\tinput.parentId,\n\t\t\t\t\t\tderivedNameType,\n\t\t\t\t\t\tfromBase64(dynamicField.name?.bcs!),\n\t\t\t\t\t),\n\t\t\t\t\ttype: normalizeStructTag(\n\t\t\t\t\t\tisDynamicObject\n\t\t\t\t\t\t\t? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type?.repr}>,0x2::object::ID>`\n\t\t\t\t\t\t\t: `0x2::dynamic_field::Field<${dynamicField.name?.type?.repr},${valueType}>`,\n\t\t\t\t\t),\n\t\t\t\t\tname: {\n\t\t\t\t\t\ttype: dynamicField.name?.type?.repr!,\n\t\t\t\t\t\tbcs: fromBase64(dynamicField.name?.bcs!),\n\t\t\t\t\t},\n\t\t\t\t\tvalueType,\n\t\t\t\t\tchildId:\n\t\t\t\t\t\tisDynamicObject && dynamicField.value?.__typename === 'MoveObject'\n\t\t\t\t\t\t\t? dynamicField.value.address\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tvalue: (includeValue ? value : undefined) as DynamicFieldEntryWithValue<Include>['value'],\n\t\t\t\t} as DynamicFieldEntryWithValue<Include>;\n\t\t\t}),\n\t\t\tcursor: result.pageInfo.endCursor ?? null,\n\t\t\thasNextPage: result.pageInfo.hasNextPage,\n\t\t};\n\t}\n\n\tgetDynamicField(\n\t\tinput: SuiClientTypes.GetDynamicFieldOptions,\n\t): Promise<SuiClientTypes.GetDynamicFieldResponse> {\n\t\treturn this.core.getDynamicField(input);\n\t}\n\n\tgetDynamicObjectField<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetDynamicObjectFieldOptions<Include>,\n\t): Promise<SuiClientTypes.GetDynamicObjectFieldResponse<Include>> {\n\t\treturn this.core.getDynamicObjectField(input);\n\t}\n\n\tlistTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.ListTransactionsOptions<Include>,\n\t): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {\n\t\treturn this.core.listTransactions(input);\n\t}\n\n\tlistEvents(input: SuiClientTypes.ListEventsOptions): Promise<SuiClientTypes.ListEventsResponse> {\n\t\treturn this.core.listEvents(input);\n\t}\n\n\tgetMoveFunction(\n\t\tinput: SuiClientTypes.GetMoveFunctionOptions,\n\t): Promise<SuiClientTypes.GetMoveFunctionResponse> {\n\t\treturn this.core.getMoveFunction(input);\n\t}\n\n\tresolveTransactionPlugin(): TransactionPlugin {\n\t\treturn this.core.resolveTransactionPlugin();\n\t}\n\n\tverifyZkLoginSignature(\n\t\tinput: SuiClientTypes.VerifyZkLoginSignatureOptions,\n\t): Promise<SuiClientTypes.ZkLoginVerifyResponse> {\n\t\treturn this.core.verifyZkLoginSignature(input);\n\t}\n\n\tdefaultNameServiceName(\n\t\tinput: SuiClientTypes.DefaultNameServiceNameOptions,\n\t): Promise<SuiClientTypes.DefaultNameServiceNameResponse> {\n\t\treturn this.core.defaultNameServiceName(input);\n\t}\n\n\tresolveNameServiceAddress(\n\t\tinput: SuiClientTypes.ResolveNameServiceAddressOptions,\n\t): Promise<SuiClientTypes.ResolveNameServiceAddressResponse> {\n\t\treturn this.core.resolveNameServiceAddress(input);\n\t}\n}\n"],"mappings":";;;;;;;;;AA2DA,IAAa,yBAAb,cAA4C,MAAM;AAElD,MAAM,mBAAmB,OAAO,IAAI,2BAA2B;AAE/D,SAAgB,mBAAmB,QAA6C;AAC/E,QACC,OAAO,WAAW,YAAY,WAAW,QAAS,OAAe,sBAAsB;;AAiCzF,IAAa,mBAAb,cACS,WAET;CACC;CACA;CACA;CACA;CAEA,IAAI,MAAiC;AACpC,SAAO,KAAK,KAAK;;CAGlB,KAAK,oBAAoB;AACxB,SAAO;;CAGR,YAAY,EACX,KACA,OAAO,UAAU,OACjB,UAAU,EAAE,EACZ,UAAU,EAAE,EACZ,SACA,OACoC;AACpC,QAAM,EACL,SACA,CAAC;AACF,QAAKA,MAAO;AACZ,QAAKC,UAAW;AAChB,QAAKC,UAAW;AAChB,QAAKC,SAAU,GAAG,SAAS,QAAQ,GAAG,KAAK;AAC3C,OAAK,OAAO,IAAI,kBAAkB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AO,GAAG;SAE7D,YAAW,IAAI,YAAY;AAE5B,aAAQ;MAAE,MAAM;MAAW,KAAK;MAAU;;AAG3C,WAAO;KACN,OAAO,kBAAkB,kBAAkB;KAC3C,SAAS,qBACR,MAAM,UACN,iBACA,WAAW,aAAa,MAAM,IAAK,CACnC;KACD,MAAM,mBACL,kBACG,gEAAgE,aAAa,MAAM,MAAM,KAAK,sBAC9F,6BAA6B,aAAa,MAAM,MAAM,KAAK,GAAG,UAAU,GAC3E;KACD,MAAM;MACL,MAAM,aAAa,MAAM,MAAM;MAC/B,KAAK,WAAW,aAAa,MAAM,IAAK;MACxC;KACD;KACA,SACC,mBAAmB,aAAa,OAAO,eAAe,eACnD,aAAa,MAAM,UACnB;KACJ,OAAQ,eAAe,QAAQ;KAC/B;KACA;GACF,QAAQ,OAAO,SAAS,aAAa;GACrC,aAAa,OAAO,SAAS;GAC7B;;CAGF,gBACC,OACkD;AAClD,SAAO,KAAK,KAAK,gBAAgB,MAAM;;CAGxC,sBACC,OACiE;AACjE,SAAO,KAAK,KAAK,sBAAsB,MAAM;;CAG9C,iBACC,OAC4D;AAC5D,SAAO,KAAK,KAAK,iBAAiB,MAAM;;CAGzC,WAAW,OAAqF;AAC/F,SAAO,KAAK,KAAK,WAAW,MAAM;;CAGnC,gBACC,OACkD;AAClD,SAAO,KAAK,KAAK,gBAAgB,MAAM;;CAGxC,2BAA8C;AAC7C,SAAO,KAAK,KAAK,0BAA0B;;CAG5C,uBACC,OACgD;AAChD,SAAO,KAAK,KAAK,uBAAuB,MAAM;;CAG/C,uBACC,OACyD;AACzD,SAAO,KAAK,KAAK,uBAAuB,MAAM;;CAG/C,0BACC,OAC4D;AAC5D,SAAO,KAAK,KAAK,0BAA0B,MAAM"}
|
|
1
|
+
{"version":3,"file":"client.mjs","names":["#url","#queries","#headers","#fetch"],"sources":["../../src/graphql/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport type { TadaDocumentNode } from 'gql.tada';\nimport type { DocumentNode } from 'graphql';\nimport { print } from 'graphql';\nimport {\n\tCLIENT_PROTOCOL_VERSION_HEADER,\n\tMAX_PROTOCOL_VERSION,\n} from '../client/protocol-version.js';\nimport { BaseClient } from '../client/index.js';\nimport type { SuiClientTypes } from '../client/index.js';\nimport { GraphQLCoreClient } from './core.js';\nimport type { TypedDocumentString } from './generated/queries.js';\nimport { GetDynamicFieldsDocument } from './generated/queries.js';\nimport { fromBase64 } from '@mysten/utils';\nimport { normalizeStructTag } from '../utils/sui-types.js';\nimport { deriveDynamicFieldID } from '../utils/dynamic-fields.js';\nimport type { TransactionPlugin } from '../transactions/index.js';\n\nexport type GraphQLDocument<Result = Record<string, unknown>, Variables = Record<string, unknown>> =\n\t| string\n\t| DocumentNode\n\t| TypedDocumentString<Result, Variables>\n\t| TypedDocumentNode<Result, Variables>\n\t| TadaDocumentNode<Result, Variables>;\n\nexport type GraphQLQueryOptions<\n\tResult = Record<string, unknown>,\n\tVariables = Record<string, unknown>,\n> = {\n\tquery: GraphQLDocument<Result, Variables>;\n\toperationName?: string;\n\textensions?: Record<string, unknown>;\n\tsignal?: AbortSignal;\n} & (Variables extends { [key: string]: never }\n\t? { variables?: Variables }\n\t: {\n\t\t\tvariables: Variables;\n\t\t});\n\nexport type GraphQLQueryResult<Result = Record<string, unknown>> = {\n\tdata?: Result;\n\terrors?: GraphQLResponseErrors;\n\textensions?: Record<string, unknown>;\n};\n\nexport type GraphQLResponseErrors = Array<{\n\tmessage: string;\n\tlocations?: { line: number; column: number }[];\n\tpath?: (string | number)[];\n}>;\n\nexport interface SuiGraphQLClientOptions<Queries extends Record<string, GraphQLDocument>> {\n\turl: string;\n\tfetch?: typeof fetch;\n\theaders?: Record<string, string>;\n\tqueries?: Queries;\n\tnetwork: SuiClientTypes.Network;\n\tmvr?: SuiClientTypes.MvrOptions;\n}\n\nexport class SuiGraphQLRequestError extends Error {}\n\nconst SUI_CLIENT_BRAND = Symbol.for('@mysten/SuiGraphQLClient') as never;\n\nexport function isSuiGraphQLClient(client: unknown): client is SuiGraphQLClient {\n\treturn (\n\t\ttypeof client === 'object' && client !== null && (client as any)[SUI_CLIENT_BRAND] === true\n\t);\n}\n\nexport interface GraphQLSimulateTransactionOptions<\n\tInclude extends SuiClientTypes.SimulateTransactionInclude = {},\n> extends SuiClientTypes.SimulateTransactionOptions<Include> {\n\t/**\n\t * Overrides whether the server selects gas payment during simulation.\n\t *\n\t * When not set, gas selection is enabled only when the transaction's gas payment is explicitly\n\t * set to an empty list (`[]`), which indicates gas is paid from the sender's address balance.\n\t * Transactions with gas coins set are simulated as-is, and transactions without a gas payment\n\t * are simulated with a mocked gas coin.\n\t */\n\tdoGasSelection?: boolean;\n}\n\nexport interface DynamicFieldInclude {\n\tvalue?: boolean;\n}\n\nexport type DynamicFieldEntryWithValue<Include extends DynamicFieldInclude = {}> =\n\tSuiClientTypes.DynamicFieldEntry & {\n\t\tvalue: Include extends { value: true } ? SuiClientTypes.DynamicFieldValue : undefined;\n\t};\n\nexport interface ListDynamicFieldsWithValueResponse<Include extends DynamicFieldInclude = {}> {\n\thasNextPage: boolean;\n\tcursor: string | null;\n\tdynamicFields: DynamicFieldEntryWithValue<Include>[];\n}\n\nexport class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> = {}>\n\textends BaseClient\n\timplements SuiClientTypes.TransportMethods\n{\n\t#url: string;\n\t#queries: Queries;\n\t#headers: Record<string, string>;\n\t#fetch: typeof fetch;\n\tcore: GraphQLCoreClient;\n\tget mvr(): SuiClientTypes.MvrMethods {\n\t\treturn this.core.mvr;\n\t}\n\n\tget [SUI_CLIENT_BRAND]() {\n\t\treturn true;\n\t}\n\n\tconstructor({\n\t\turl,\n\t\tfetch: fetchFn = fetch,\n\t\theaders = {},\n\t\tqueries = {} as Queries,\n\t\tnetwork,\n\t\tmvr,\n\t}: SuiGraphQLClientOptions<Queries>) {\n\t\tsuper({\n\t\t\tnetwork,\n\t\t});\n\t\tthis.#url = url;\n\t\tthis.#queries = queries;\n\t\tthis.#headers = headers;\n\t\tthis.#fetch = (...args) => fetchFn(...args);\n\t\tthis.core = new GraphQLCoreClient({\n\t\t\tgraphqlClient: this,\n\t\t\tmvr,\n\t\t});\n\t}\n\n\tasync query<Result = Record<string, unknown>, Variables = Record<string, unknown>>(\n\t\toptions: GraphQLQueryOptions<Result, Variables>,\n\t): Promise<GraphQLQueryResult<Result>> {\n\t\tconst headers = new Headers({\n\t\t\t'Content-Type': 'application/json',\n\t\t\t...this.#headers,\n\t\t});\n\t\tif (!headers.has(CLIENT_PROTOCOL_VERSION_HEADER)) {\n\t\t\theaders.set(CLIENT_PROTOCOL_VERSION_HEADER, String(MAX_PROTOCOL_VERSION));\n\t\t}\n\n\t\tconst res = await this.#fetch(this.#url, {\n\t\t\tmethod: 'POST',\n\t\t\theaders,\n\t\t\tbody: JSON.stringify({\n\t\t\t\tquery:\n\t\t\t\t\ttypeof options.query === 'string' || options.query instanceof String\n\t\t\t\t\t\t? String(options.query)\n\t\t\t\t\t\t: print(options.query),\n\t\t\t\tvariables: options.variables,\n\t\t\t\textensions: options.extensions,\n\t\t\t\toperationName: options.operationName,\n\t\t\t}),\n\t\t\tsignal: options.signal,\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new SuiGraphQLRequestError(`GraphQL request failed: ${res.statusText} (${res.status})`);\n\t\t}\n\n\t\treturn await res.json();\n\t}\n\n\tasync execute<\n\t\tconst Query extends Extract<keyof Queries, string>,\n\t\tResult = Queries[Query] extends GraphQLDocument<infer R, unknown> ? R : Record<string, unknown>,\n\t\tVariables = Queries[Query] extends GraphQLDocument<unknown, infer V>\n\t\t\t? V\n\t\t\t: Record<string, unknown>,\n\t>(\n\t\tquery: Query,\n\t\toptions: Omit<GraphQLQueryOptions<Result, Variables>, 'query'>,\n\t): Promise<GraphQLQueryResult<Result>> {\n\t\treturn this.query({\n\t\t\t...(options as { variables: Record<string, unknown> }),\n\t\t\tquery: this.#queries[query]!,\n\t\t}) as Promise<GraphQLQueryResult<Result>>;\n\t}\n\n\tgetObjects<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetObjectsOptions<Include>,\n\t): Promise<SuiClientTypes.GetObjectsResponse<Include>> {\n\t\treturn this.core.getObjects(input);\n\t}\n\n\tgetObject<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetObjectOptions<Include>,\n\t): Promise<SuiClientTypes.GetObjectResponse<Include>> {\n\t\treturn this.core.getObject(input);\n\t}\n\n\tlistCoins(input: SuiClientTypes.ListCoinsOptions): Promise<SuiClientTypes.ListCoinsResponse> {\n\t\treturn this.core.listCoins(input);\n\t}\n\n\tlistOwnedObjects<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.ListOwnedObjectsOptions<Include>,\n\t): Promise<SuiClientTypes.ListOwnedObjectsResponse<Include>> {\n\t\treturn this.core.listOwnedObjects(input);\n\t}\n\n\tgetBalance(input: SuiClientTypes.GetBalanceOptions): Promise<SuiClientTypes.GetBalanceResponse> {\n\t\treturn this.core.getBalance(input);\n\t}\n\n\tlistBalances(\n\t\tinput: SuiClientTypes.ListBalancesOptions,\n\t): Promise<SuiClientTypes.ListBalancesResponse> {\n\t\treturn this.core.listBalances(input);\n\t}\n\n\tgetCoinMetadata(\n\t\tinput: SuiClientTypes.GetCoinMetadataOptions,\n\t): Promise<SuiClientTypes.GetCoinMetadataResponse> {\n\t\treturn this.core.getCoinMetadata(input);\n\t}\n\n\tgetTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.GetTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.getTransaction(input);\n\t}\n\n\texecuteTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.ExecuteTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.executeTransaction(input);\n\t}\n\n\tsignAndExecuteTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.SignAndExecuteTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.signAndExecuteTransaction(input);\n\t}\n\n\twaitForTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.WaitForTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.waitForTransaction(input);\n\t}\n\n\tsimulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(\n\t\tinput: GraphQLSimulateTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {\n\t\treturn this.core.simulateTransaction(input);\n\t}\n\n\tgetReferenceGasPrice(\n\t\tinput?: SuiClientTypes.GetReferenceGasPriceOptions,\n\t): Promise<SuiClientTypes.GetReferenceGasPriceResponse> {\n\t\treturn this.core.getReferenceGasPrice(input);\n\t}\n\n\tgetCurrentSystemState(\n\t\tinput?: SuiClientTypes.GetCurrentSystemStateOptions,\n\t): Promise<SuiClientTypes.GetCurrentSystemStateResponse> {\n\t\treturn this.core.getCurrentSystemState(input);\n\t}\n\n\tgetProtocolConfig(\n\t\tinput?: SuiClientTypes.GetProtocolConfigOptions,\n\t): Promise<SuiClientTypes.GetProtocolConfigResponse> {\n\t\treturn this.core.getProtocolConfig(input);\n\t}\n\n\tgetChainIdentifier(\n\t\tinput?: SuiClientTypes.GetChainIdentifierOptions,\n\t): Promise<SuiClientTypes.GetChainIdentifierResponse> {\n\t\treturn this.core.getChainIdentifier(input);\n\t}\n\n\tasync listDynamicFields<Include extends DynamicFieldInclude = {}>(\n\t\tinput: SuiClientTypes.ListDynamicFieldsOptions & { include?: Include & DynamicFieldInclude },\n\t): Promise<ListDynamicFieldsWithValueResponse<Include>> {\n\t\tconst includeValue = input.include?.value ?? false;\n\n\t\tconst { data, errors } = await this.query({\n\t\t\tquery: GetDynamicFieldsDocument,\n\t\t\tsignal: input.signal,\n\t\t\tvariables: {\n\t\t\t\tparentId: input.parentId,\n\t\t\t\tfirst: input.limit,\n\t\t\t\tcursor: input.cursor,\n\t\t\t\tincludeValue,\n\t\t\t},\n\t\t});\n\n\t\tif (errors?.length) {\n\t\t\tthrow errors.length === 1\n\t\t\t\t? new Error(errors[0].message)\n\t\t\t\t: new AggregateError(errors.map((e) => new Error(e.message)));\n\t\t}\n\n\t\tconst result = data?.address?.dynamicFields;\n\t\tif (!result) {\n\t\t\tthrow new Error('Missing response data');\n\t\t}\n\n\t\treturn {\n\t\t\tdynamicFields: result.nodes.map((dynamicField): DynamicFieldEntryWithValue<Include> => {\n\t\t\t\tconst valueType =\n\t\t\t\t\tdynamicField.value?.__typename === 'MoveObject'\n\t\t\t\t\t\t? dynamicField.value.contents?.type?.repr!\n\t\t\t\t\t\t: dynamicField.value?.type?.repr!;\n\t\t\t\tconst isDynamicObject = dynamicField.value?.__typename === 'MoveObject';\n\t\t\t\tconst derivedNameType = isDynamicObject\n\t\t\t\t\t? `0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type?.repr}>`\n\t\t\t\t\t: dynamicField.name?.type?.repr!;\n\n\t\t\t\tlet value: SuiClientTypes.DynamicFieldValue | undefined;\n\t\t\t\tif (includeValue) {\n\t\t\t\t\tlet valueBcs: Uint8Array;\n\t\t\t\t\tif (dynamicField.value?.__typename === 'MoveValue') {\n\t\t\t\t\t\tvalueBcs = fromBase64(dynamicField.value.bcs ?? '');\n\t\t\t\t\t} else if (dynamicField.value?.__typename === 'MoveObject') {\n\t\t\t\t\t\tvalueBcs = fromBase64(dynamicField.value.contents?.bcs ?? '');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalueBcs = new Uint8Array();\n\t\t\t\t\t}\n\t\t\t\t\tvalue = { type: valueType, bcs: valueBcs };\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',\n\t\t\t\t\tfieldId: deriveDynamicFieldID(\n\t\t\t\t\t\tinput.parentId,\n\t\t\t\t\t\tderivedNameType,\n\t\t\t\t\t\tfromBase64(dynamicField.name?.bcs!),\n\t\t\t\t\t),\n\t\t\t\t\ttype: normalizeStructTag(\n\t\t\t\t\t\tisDynamicObject\n\t\t\t\t\t\t\t? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type?.repr}>,0x2::object::ID>`\n\t\t\t\t\t\t\t: `0x2::dynamic_field::Field<${dynamicField.name?.type?.repr},${valueType}>`,\n\t\t\t\t\t),\n\t\t\t\t\tname: {\n\t\t\t\t\t\ttype: dynamicField.name?.type?.repr!,\n\t\t\t\t\t\tbcs: fromBase64(dynamicField.name?.bcs!),\n\t\t\t\t\t},\n\t\t\t\t\tvalueType,\n\t\t\t\t\tchildId:\n\t\t\t\t\t\tisDynamicObject && dynamicField.value?.__typename === 'MoveObject'\n\t\t\t\t\t\t\t? dynamicField.value.address\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tvalue: (includeValue ? value : undefined) as DynamicFieldEntryWithValue<Include>['value'],\n\t\t\t\t} as DynamicFieldEntryWithValue<Include>;\n\t\t\t}),\n\t\t\tcursor: result.pageInfo.endCursor ?? null,\n\t\t\thasNextPage: result.pageInfo.hasNextPage,\n\t\t};\n\t}\n\n\tgetDynamicField(\n\t\tinput: SuiClientTypes.GetDynamicFieldOptions,\n\t): Promise<SuiClientTypes.GetDynamicFieldResponse> {\n\t\treturn this.core.getDynamicField(input);\n\t}\n\n\tgetDynamicObjectField<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetDynamicObjectFieldOptions<Include>,\n\t): Promise<SuiClientTypes.GetDynamicObjectFieldResponse<Include>> {\n\t\treturn this.core.getDynamicObjectField(input);\n\t}\n\n\tlistTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.ListTransactionsOptions<Include>,\n\t): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {\n\t\treturn this.core.listTransactions(input);\n\t}\n\n\tlistEvents(input: SuiClientTypes.ListEventsOptions): Promise<SuiClientTypes.ListEventsResponse> {\n\t\treturn this.core.listEvents(input);\n\t}\n\n\tgetMoveFunction(\n\t\tinput: SuiClientTypes.GetMoveFunctionOptions,\n\t): Promise<SuiClientTypes.GetMoveFunctionResponse> {\n\t\treturn this.core.getMoveFunction(input);\n\t}\n\n\tresolveTransactionPlugin(): TransactionPlugin {\n\t\treturn this.core.resolveTransactionPlugin();\n\t}\n\n\tverifyZkLoginSignature(\n\t\tinput: SuiClientTypes.VerifyZkLoginSignatureOptions,\n\t): Promise<SuiClientTypes.ZkLoginVerifyResponse> {\n\t\treturn this.core.verifyZkLoginSignature(input);\n\t}\n\n\tdefaultNameServiceName(\n\t\tinput: SuiClientTypes.DefaultNameServiceNameOptions,\n\t): Promise<SuiClientTypes.DefaultNameServiceNameResponse> {\n\t\treturn this.core.defaultNameServiceName(input);\n\t}\n\n\tresolveNameServiceAddress(\n\t\tinput: SuiClientTypes.ResolveNameServiceAddressOptions,\n\t): Promise<SuiClientTypes.ResolveNameServiceAddressResponse> {\n\t\treturn this.core.resolveNameServiceAddress(input);\n\t}\n}\n"],"mappings":";;;;;;;;;;AA+DA,IAAa,yBAAb,cAA4C,MAAM;AAElD,MAAM,mBAAmB,OAAO,IAAI,2BAA2B;AAE/D,SAAgB,mBAAmB,QAA6C;AAC/E,QACC,OAAO,WAAW,YAAY,WAAW,QAAS,OAAe,sBAAsB;;AAiCzF,IAAa,mBAAb,cACS,WAET;CACC;CACA;CACA;CACA;CAEA,IAAI,MAAiC;AACpC,SAAO,KAAK,KAAK;;CAGlB,KAAK,oBAAoB;AACxB,SAAO;;CAGR,YAAY,EACX,KACA,OAAO,UAAU,OACjB,UAAU,EAAE,EACZ,UAAU,EAAE,EACZ,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C,KAAA,EAAO,cAAA,CAAe,sBAAA,GACpB,OAAA,CAAQ,cAAA,CAAe,uBAAA;EAI1B,wBAAA,CAAA,GAA4B,iBAAA;EAI5B,sBAAA,CACC,KAAA,EAAO,cAAA,CAAe,6BAAA,GACpB,OAAA,CAAQ,cAAA,CAAe,qBAAA;EAI1B,sBAAA,CACC,KAAA,EAAO,cAAA,CAAe,6BAAA,GACpB,OAAA,CAAQ,cAAA,CAAe,8BAAA;EAI1B,yBAAA,CACC,KAAA,EAAO,cAAA,CAAe,gCAAA,GACpB,OAAA,CAAQ,cAAA,CAAe,iCAAA;AAAA"}
|
package/dist/grpc/client.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { SignatureVerificationServiceClient } from "./proto/sui/rpc/v2/signature
|
|
|
7
7
|
import { DynamicField_DynamicFieldKind } from "./proto/sui/rpc/v2/state_service.mjs";
|
|
8
8
|
import { StateServiceClient } from "./proto/sui/rpc/v2/state_service.client.mjs";
|
|
9
9
|
import { SubscriptionServiceClient } from "./proto/sui/rpc/v2/subscription_service.client.mjs";
|
|
10
|
-
import { GrpcWebFetchTransport } from "./transport.mjs";
|
|
10
|
+
import { GrpcWebFetchTransport, withClientProtocolVersion } from "./transport.mjs";
|
|
11
11
|
import { GrpcCoreClient } from "./core.mjs";
|
|
12
12
|
import { NameServiceClient } from "./proto/sui/rpc/v2/name_service.client.mjs";
|
|
13
13
|
import { ForkingServiceClient } from "./proto/sui/forking/v1alpha/forking_service.client.mjs";
|
|
@@ -28,7 +28,7 @@ var SuiGrpcClient = class extends BaseClient {
|
|
|
28
28
|
constructor(options) {
|
|
29
29
|
super({ network: options.network });
|
|
30
30
|
const { network: _network, mvr: _mvr, abort: _abort, transport: providedTransport, ...transportOptions } = options;
|
|
31
|
-
const transport = providedTransport ?? new GrpcWebFetchTransport(transportOptions);
|
|
31
|
+
const transport = withClientProtocolVersion(providedTransport ?? new GrpcWebFetchTransport(transportOptions));
|
|
32
32
|
this.transactionExecutionService = new TransactionExecutionServiceClient(transport);
|
|
33
33
|
this.ledgerService = new LedgerServiceClient(transport);
|
|
34
34
|
this.stateService = new StateServiceClient(transport);
|
package/dist/grpc/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","names":[],"sources":["../../src/grpc/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { GrpcWebOptions } from '@protobuf-ts/grpcweb-transport';\nimport { TransactionExecutionServiceClient } from './proto/sui/rpc/v2/transaction_execution_service.client.js';\nimport { LedgerServiceClient } from './proto/sui/rpc/v2/ledger_service.client.js';\nimport { MovePackageServiceClient } from './proto/sui/rpc/v2/move_package_service.client.js';\nimport { SignatureVerificationServiceClient } from './proto/sui/rpc/v2/signature_verification_service.client.js';\nimport type { RpcTransport } from '@protobuf-ts/runtime-rpc';\nimport { StateServiceClient } from './proto/sui/rpc/v2/state_service.client.js';\nimport { SubscriptionServiceClient } from './proto/sui/rpc/v2/subscription_service.client.js';\nimport { GrpcCoreClient } from './core.js';\nimport type { SuiClientTypes } from '../client/index.js';\nimport { BaseClient } from '../client/index.js';\nimport { DynamicField_DynamicFieldKind } from './proto/sui/rpc/v2/state_service.js';\nimport { normalizeStructTag } from '../utils/sui-types.js';\nimport { fromBase64, toBase64 } from '@mysten/utils';\nimport { NameServiceClient } from './proto/sui/rpc/v2/name_service.client.js';\nimport { ForkingServiceClient } from './proto/sui/forking/v1alpha/forking_service.client.js';\nimport type { TransactionPlugin } from '../transactions/index.js';\nimport { GrpcWebFetchTransport } from './transport.js';\n\ninterface SuiGrpcTransportOptions extends GrpcWebOptions {\n\ttransport?: never;\n}\n\nexport type SuiGrpcClientOptions = {\n\tnetwork: SuiClientTypes.Network;\n\tmvr?: SuiClientTypes.MvrOptions;\n} & (\n\t| {\n\t\t\ttransport: RpcTransport;\n\t }\n\t| SuiGrpcTransportOptions\n);\n\nconst SUI_CLIENT_BRAND = Symbol.for('@mysten/SuiGrpcClient') as never;\n\nexport function isSuiGrpcClient(client: unknown): client is SuiGrpcClient {\n\treturn (\n\t\ttypeof client === 'object' && client !== null && (client as any)[SUI_CLIENT_BRAND] === true\n\t);\n}\n\nexport interface DynamicFieldInclude {\n\tvalue?: boolean;\n}\n\nexport type DynamicFieldEntryWithValue<Include extends DynamicFieldInclude = {}> =\n\tSuiClientTypes.DynamicFieldEntry & {\n\t\tvalue: Include extends { value: true } ? SuiClientTypes.DynamicFieldValue : undefined;\n\t};\n\nexport interface ListDynamicFieldsWithValueResponse<Include extends DynamicFieldInclude = {}> {\n\thasNextPage: boolean;\n\tcursor: string | null;\n\tdynamicFields: DynamicFieldEntryWithValue<Include>[];\n}\n\nexport interface GrpcTransactionInclude extends SuiClientTypes.TransactionInclude {\n\t/** Include the parsed protobuf JSON value for the gRPC transaction response. */\n\tprotoJson?: boolean;\n}\n\nexport interface GrpcSimulateTransactionInclude extends SuiClientTypes.SimulateTransactionInclude {\n\t/** Include the parsed protobuf JSON value for the gRPC simulation response. */\n\tprotoJson?: boolean;\n}\n\nexport type GrpcTransactionProtoJson = ReturnType<\n\ttypeof import('./proto/sui/rpc/v2/executed_transaction.js').ExecutedTransaction.toJson\n>;\n\nexport type GrpcSimulateTransactionProtoJson = ReturnType<\n\ttypeof import('./proto/sui/rpc/v2/transaction_execution_service.js').SimulateTransactionResponse.toJson\n>;\n\ntype ProtoJson<Include extends { protoJson?: boolean }, Json> = Include['protoJson'] extends true\n\t? Json\n\t: undefined;\n\nexport type GrpcTransactionResult<Include extends GrpcTransactionInclude = {}> =\n\tSuiClientTypes.TransactionResult<Include> & {\n\t\tprotoJson: ProtoJson<Include, GrpcTransactionProtoJson>;\n\t};\n\nexport type GrpcSimulateTransactionResult<Include extends GrpcSimulateTransactionInclude = {}> =\n\tSuiClientTypes.SimulateTransactionResult<Include> & {\n\t\tprotoJson: ProtoJson<Include, GrpcSimulateTransactionProtoJson>;\n\t};\n\nexport interface GrpcGetTransactionOptions<\n\tInclude extends GrpcTransactionInclude = {},\n> extends SuiClientTypes.GetTransactionOptions<Include> {\n\tinclude?: Include & GrpcTransactionInclude;\n}\n\nexport interface GrpcWaitForTransactionByDigest<\n\tInclude extends GrpcTransactionInclude = {},\n> extends SuiClientTypes.WaitForTransactionByDigest<Include> {\n\tinclude?: Include & GrpcTransactionInclude;\n}\n\nexport interface GrpcWaitForTransactionByResult<\n\tInclude extends GrpcTransactionInclude = {},\n> extends SuiClientTypes.WaitForTransactionByResult<Include> {\n\tinclude?: Include & GrpcTransactionInclude;\n}\n\nexport type GrpcWaitForTransactionOptions<Include extends GrpcTransactionInclude = {}> =\n\tGrpcWaitForTransactionByDigest<Include> | GrpcWaitForTransactionByResult<Include>;\n\nexport interface GrpcExecuteTransactionOptions<\n\tInclude extends GrpcTransactionInclude = {},\n> extends SuiClientTypes.ExecuteTransactionOptions<Include> {\n\tinclude?: Include & GrpcTransactionInclude;\n}\n\nexport interface GrpcSignAndExecuteTransactionOptions<\n\tInclude extends GrpcTransactionInclude = {},\n> extends SuiClientTypes.SignAndExecuteTransactionOptions<Include> {\n\tinclude?: Include & GrpcTransactionInclude;\n}\n\nexport interface GrpcSimulateTransactionOptions<\n\tInclude extends GrpcSimulateTransactionInclude = {},\n> extends SuiClientTypes.SimulateTransactionOptions<Include> {\n\tinclude?: Include & GrpcSimulateTransactionInclude;\n\t/**\n\t * Overrides whether the server selects gas payment during simulation.\n\t *\n\t * When not set, gas selection is enabled only when the transaction's gas payment is explicitly\n\t * set to an empty list (`[]`), which indicates gas is paid from the sender's address balance.\n\t * Transactions with gas coins set are simulated as-is, and transactions without a gas payment\n\t * are simulated with a mocked gas coin.\n\t */\n\tdoGasSelection?: boolean;\n}\n\nexport class SuiGrpcClient extends BaseClient implements SuiClientTypes.TransportMethods {\n\tcore: GrpcCoreClient;\n\tget mvr(): SuiClientTypes.MvrMethods {\n\t\treturn this.core.mvr;\n\t}\n\ttransactionExecutionService: TransactionExecutionServiceClient;\n\tledgerService: LedgerServiceClient;\n\tstateService: StateServiceClient;\n\tsubscriptionService: SubscriptionServiceClient;\n\tmovePackageService: MovePackageServiceClient;\n\tsignatureVerificationService: SignatureVerificationServiceClient;\n\tnameService: NameServiceClient;\n\tforkingService: ForkingServiceClient;\n\n\tget [SUI_CLIENT_BRAND]() {\n\t\treturn true;\n\t}\n\n\tconstructor(options: SuiGrpcClientOptions) {\n\t\tsuper({ network: options.network });\n\t\tconst {\n\t\t\tnetwork: _network,\n\t\t\tmvr: _mvr,\n\t\t\t// Not forwarded: every Core API call passes its own `signal`, which would overwrite it.\n\t\t\tabort: _abort,\n\t\t\ttransport: providedTransport,\n\t\t\t...transportOptions\n\t\t} = options as SuiGrpcClientOptions & SuiGrpcTransportOptions & { transport?: RpcTransport };\n\n\t\t// A caller-supplied transport is used as given. See ./transport.ts for the default.\n\t\tconst transport = providedTransport ?? new GrpcWebFetchTransport(transportOptions);\n\t\tthis.transactionExecutionService = new TransactionExecutionServiceClient(transport);\n\t\tthis.ledgerService = new LedgerServiceClient(transport);\n\t\tthis.stateService = new StateServiceClient(transport);\n\t\tthis.subscriptionService = new SubscriptionServiceClient(transport);\n\t\tthis.movePackageService = new MovePackageServiceClient(transport);\n\t\tthis.signatureVerificationService = new SignatureVerificationServiceClient(transport);\n\t\tthis.nameService = new NameServiceClient(transport);\n\t\tthis.forkingService = new ForkingServiceClient(transport);\n\n\t\tthis.core = new GrpcCoreClient({\n\t\t\tclient: this,\n\t\t\tbase: this,\n\t\t\tnetwork: options.network,\n\t\t\tmvr: options.mvr,\n\t\t});\n\t}\n\n\tgetObjects<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetObjectsOptions<Include>,\n\t): Promise<SuiClientTypes.GetObjectsResponse<Include>> {\n\t\treturn this.core.getObjects(input);\n\t}\n\n\tgetObject<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetObjectOptions<Include>,\n\t): Promise<SuiClientTypes.GetObjectResponse<Include>> {\n\t\treturn this.core.getObject(input);\n\t}\n\n\tlistCoins(input: SuiClientTypes.ListCoinsOptions): Promise<SuiClientTypes.ListCoinsResponse> {\n\t\treturn this.core.listCoins(input);\n\t}\n\n\tlistOwnedObjects<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.ListOwnedObjectsOptions<Include>,\n\t): Promise<SuiClientTypes.ListOwnedObjectsResponse<Include>> {\n\t\treturn this.core.listOwnedObjects(input);\n\t}\n\n\tgetBalance(input: SuiClientTypes.GetBalanceOptions): Promise<SuiClientTypes.GetBalanceResponse> {\n\t\treturn this.core.getBalance(input);\n\t}\n\n\tlistBalances(\n\t\tinput: SuiClientTypes.ListBalancesOptions,\n\t): Promise<SuiClientTypes.ListBalancesResponse> {\n\t\treturn this.core.listBalances(input);\n\t}\n\n\tgetCoinMetadata(\n\t\tinput: SuiClientTypes.GetCoinMetadataOptions,\n\t): Promise<SuiClientTypes.GetCoinMetadataResponse> {\n\t\treturn this.core.getCoinMetadata(input);\n\t}\n\n\tgetTransaction<Include extends GrpcTransactionInclude = {}>(\n\t\tinput: GrpcGetTransactionOptions<Include>,\n\t): Promise<GrpcTransactionResult<Include>> {\n\t\treturn this.core.getTransaction(input) as Promise<GrpcTransactionResult<Include>>;\n\t}\n\n\texecuteTransaction<Include extends GrpcTransactionInclude = {}>(\n\t\tinput: GrpcExecuteTransactionOptions<Include>,\n\t): Promise<GrpcTransactionResult<Include>> {\n\t\treturn this.core.executeTransaction(input) as Promise<GrpcTransactionResult<Include>>;\n\t}\n\n\tsignAndExecuteTransaction<Include extends GrpcTransactionInclude = {}>(\n\t\tinput: GrpcSignAndExecuteTransactionOptions<Include>,\n\t): Promise<GrpcTransactionResult<Include>> {\n\t\treturn this.core.signAndExecuteTransaction(input) as Promise<GrpcTransactionResult<Include>>;\n\t}\n\n\twaitForTransaction<Include extends GrpcTransactionInclude = {}>(\n\t\tinput: GrpcWaitForTransactionOptions<Include>,\n\t): Promise<GrpcTransactionResult<Include>> {\n\t\treturn this.core.waitForTransaction(input) as Promise<GrpcTransactionResult<Include>>;\n\t}\n\n\tsimulateTransaction<Include extends GrpcSimulateTransactionInclude = {}>(\n\t\tinput: GrpcSimulateTransactionOptions<Include>,\n\t): Promise<GrpcSimulateTransactionResult<Include>> {\n\t\treturn this.core.simulateTransaction(input) as Promise<GrpcSimulateTransactionResult<Include>>;\n\t}\n\n\tgetReferenceGasPrice(\n\t\tinput?: SuiClientTypes.GetReferenceGasPriceOptions,\n\t): Promise<SuiClientTypes.GetReferenceGasPriceResponse> {\n\t\treturn this.core.getReferenceGasPrice(input);\n\t}\n\n\tgetCurrentSystemState(\n\t\tinput?: SuiClientTypes.GetCurrentSystemStateOptions,\n\t): Promise<SuiClientTypes.GetCurrentSystemStateResponse> {\n\t\treturn this.core.getCurrentSystemState(input);\n\t}\n\n\tgetProtocolConfig(\n\t\tinput?: SuiClientTypes.GetProtocolConfigOptions,\n\t): Promise<SuiClientTypes.GetProtocolConfigResponse> {\n\t\treturn this.core.getProtocolConfig(input);\n\t}\n\n\tgetChainIdentifier(\n\t\tinput?: SuiClientTypes.GetChainIdentifierOptions,\n\t): Promise<SuiClientTypes.GetChainIdentifierResponse> {\n\t\treturn this.core.getChainIdentifier(input);\n\t}\n\n\tasync listDynamicFields<Include extends DynamicFieldInclude = {}>(\n\t\tinput: SuiClientTypes.ListDynamicFieldsOptions & { include?: Include & DynamicFieldInclude },\n\t): Promise<ListDynamicFieldsWithValueResponse<Include>> {\n\t\tconst includeValue = input.include?.value ?? false;\n\t\tconst paths = ['field_id', 'name', 'value_type', 'kind', 'child_id'];\n\t\tif (includeValue) {\n\t\t\tpaths.push('value');\n\t\t}\n\n\t\tconst response = await this.stateService.listDynamicFields(\n\t\t\t{\n\t\t\t\tparent: input.parentId,\n\t\t\t\tpageToken: input.cursor ? fromBase64(input.cursor) : undefined,\n\t\t\t\tpageSize: input.limit,\n\t\t\t\treadMask: {\n\t\t\t\t\tpaths,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ abort: input.signal },\n\t\t);\n\n\t\treturn {\n\t\t\tdynamicFields: response.response.dynamicFields.map(\n\t\t\t\t(field): DynamicFieldEntryWithValue<Include> => {\n\t\t\t\t\tconst isDynamicObject = field.kind === DynamicField_DynamicFieldKind.OBJECT;\n\t\t\t\t\tconst fieldType = isDynamicObject\n\t\t\t\t\t\t? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${field.name?.name!}>,0x2::object::ID>`\n\t\t\t\t\t\t: `0x2::dynamic_field::Field<${field.name?.name!},${field.valueType!}>`;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',\n\t\t\t\t\t\tfieldId: field.fieldId!,\n\t\t\t\t\t\tname: {\n\t\t\t\t\t\t\ttype: field.name?.name!,\n\t\t\t\t\t\t\tbcs: field.name?.value!,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalueType: field.valueType!,\n\t\t\t\t\t\ttype: normalizeStructTag(fieldType),\n\t\t\t\t\t\tchildId: field.childId,\n\t\t\t\t\t\tvalue: (includeValue\n\t\t\t\t\t\t\t? { type: field.valueType!, bcs: field.value?.value ?? new Uint8Array() }\n\t\t\t\t\t\t\t: undefined) as DynamicFieldEntryWithValue<Include>['value'],\n\t\t\t\t\t} as DynamicFieldEntryWithValue<Include>;\n\t\t\t\t},\n\t\t\t),\n\t\t\tcursor: response.response.nextPageToken ? toBase64(response.response.nextPageToken) : null,\n\t\t\thasNextPage: response.response.nextPageToken !== undefined,\n\t\t};\n\t}\n\n\tgetDynamicField(\n\t\tinput: SuiClientTypes.GetDynamicFieldOptions,\n\t): Promise<SuiClientTypes.GetDynamicFieldResponse> {\n\t\treturn this.core.getDynamicField(input);\n\t}\n\n\tgetDynamicObjectField<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetDynamicObjectFieldOptions<Include>,\n\t): Promise<SuiClientTypes.GetDynamicObjectFieldResponse<Include>> {\n\t\treturn this.core.getDynamicObjectField(input);\n\t}\n\n\tlistTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.ListTransactionsOptions<Include>,\n\t): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {\n\t\treturn this.core.listTransactions(input);\n\t}\n\n\tlistEvents(input: SuiClientTypes.ListEventsOptions): Promise<SuiClientTypes.ListEventsResponse> {\n\t\treturn this.core.listEvents(input);\n\t}\n\n\tgetMoveFunction(\n\t\tinput: SuiClientTypes.GetMoveFunctionOptions,\n\t): Promise<SuiClientTypes.GetMoveFunctionResponse> {\n\t\treturn this.core.getMoveFunction(input);\n\t}\n\n\tresolveTransactionPlugin(): TransactionPlugin {\n\t\treturn this.core.resolveTransactionPlugin();\n\t}\n\n\tverifyZkLoginSignature(\n\t\tinput: SuiClientTypes.VerifyZkLoginSignatureOptions,\n\t): Promise<SuiClientTypes.ZkLoginVerifyResponse> {\n\t\treturn this.core.verifyZkLoginSignature(input);\n\t}\n\n\tdefaultNameServiceName(\n\t\tinput: SuiClientTypes.DefaultNameServiceNameOptions,\n\t): Promise<SuiClientTypes.DefaultNameServiceNameResponse> {\n\t\treturn this.core.defaultNameServiceName(input);\n\t}\n\n\tresolveNameServiceAddress(\n\t\tinput: SuiClientTypes.ResolveNameServiceAddressOptions,\n\t): Promise<SuiClientTypes.ResolveNameServiceAddressResponse> {\n\t\treturn this.core.resolveNameServiceAddress(input);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,MAAM,mBAAmB,OAAO,IAAI,wBAAwB;AAE5D,SAAgB,gBAAgB,QAA0C;AACzE,QACC,OAAO,WAAW,YAAY,WAAW,QAAS,OAAe,sBAAsB;;AAmGzF,IAAa,gBAAb,cAAmC,WAAsD;CAExF,IAAI,MAAiC;AACpC,SAAO,KAAK,KAAK;;CAWlB,KAAK,oBAAoB;AACxB,SAAO;;CAGR,YAAY,SAA+B;AAC1C,QAAM,EAAE,SA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kD;AAClD,SAAO,KAAK,KAAK,gBAAgB,MAAM;;CAGxC,sBACC,OACiE;AACjE,SAAO,KAAK,KAAK,sBAAsB,MAAM;;CAG9C,iBACC,OAC4D;AAC5D,SAAO,KAAK,KAAK,iBAAiB,MAAM;;CAGzC,WAAW,OAAqF;AAC/F,SAAO,KAAK,KAAK,WAAW,MAAM;;CAGnC,gBACC,OACkD;AAClD,SAAO,KAAK,KAAK,gBAAgB,MAAM;;CAGxC,2BAA8C;AAC7C,SAAO,KAAK,KAAK,0BAA0B;;CAG5C,uBACC,OACgD;AAChD,SAAO,KAAK,KAAK,uBAAuB,MAAM;;CAG/C,uBACC,OACyD;AACzD,SAAO,KAAK,KAAK,uBAAuB,MAAM;;CAG/C,0BACC,OAC4D;AAC5D,SAAO,KAAK,KAAK,0BAA0B,MAAM"}
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../../src/grpc/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { GrpcWebOptions } from '@protobuf-ts/grpcweb-transport';\nimport { TransactionExecutionServiceClient } from './proto/sui/rpc/v2/transaction_execution_service.client.js';\nimport { LedgerServiceClient } from './proto/sui/rpc/v2/ledger_service.client.js';\nimport { MovePackageServiceClient } from './proto/sui/rpc/v2/move_package_service.client.js';\nimport { SignatureVerificationServiceClient } from './proto/sui/rpc/v2/signature_verification_service.client.js';\nimport type { RpcTransport } from '@protobuf-ts/runtime-rpc';\nimport { StateServiceClient } from './proto/sui/rpc/v2/state_service.client.js';\nimport { SubscriptionServiceClient } from './proto/sui/rpc/v2/subscription_service.client.js';\nimport { GrpcCoreClient } from './core.js';\nimport type { SuiClientTypes } from '../client/index.js';\nimport { BaseClient } from '../client/index.js';\nimport { DynamicField_DynamicFieldKind } from './proto/sui/rpc/v2/state_service.js';\nimport { normalizeStructTag } from '../utils/sui-types.js';\nimport { fromBase64, toBase64 } from '@mysten/utils';\nimport { NameServiceClient } from './proto/sui/rpc/v2/name_service.client.js';\nimport { ForkingServiceClient } from './proto/sui/forking/v1alpha/forking_service.client.js';\nimport type { TransactionPlugin } from '../transactions/index.js';\nimport { GrpcWebFetchTransport, withClientProtocolVersion } from './transport.js';\n\ninterface SuiGrpcTransportOptions extends GrpcWebOptions {\n\ttransport?: never;\n}\n\nexport type SuiGrpcClientOptions = {\n\tnetwork: SuiClientTypes.Network;\n\tmvr?: SuiClientTypes.MvrOptions;\n} & (\n\t| {\n\t\t\ttransport: RpcTransport;\n\t }\n\t| SuiGrpcTransportOptions\n);\n\nconst SUI_CLIENT_BRAND = Symbol.for('@mysten/SuiGrpcClient') as never;\n\nexport function isSuiGrpcClient(client: unknown): client is SuiGrpcClient {\n\treturn (\n\t\ttypeof client === 'object' && client !== null && (client as any)[SUI_CLIENT_BRAND] === true\n\t);\n}\n\nexport interface DynamicFieldInclude {\n\tvalue?: boolean;\n}\n\nexport type DynamicFieldEntryWithValue<Include extends DynamicFieldInclude = {}> =\n\tSuiClientTypes.DynamicFieldEntry & {\n\t\tvalue: Include extends { value: true } ? SuiClientTypes.DynamicFieldValue : undefined;\n\t};\n\nexport interface ListDynamicFieldsWithValueResponse<Include extends DynamicFieldInclude = {}> {\n\thasNextPage: boolean;\n\tcursor: string | null;\n\tdynamicFields: DynamicFieldEntryWithValue<Include>[];\n}\n\nexport interface GrpcTransactionInclude extends SuiClientTypes.TransactionInclude {\n\t/** Include the parsed protobuf JSON value for the gRPC transaction response. */\n\tprotoJson?: boolean;\n}\n\nexport interface GrpcSimulateTransactionInclude extends SuiClientTypes.SimulateTransactionInclude {\n\t/** Include the parsed protobuf JSON value for the gRPC simulation response. */\n\tprotoJson?: boolean;\n}\n\nexport type GrpcTransactionProtoJson = ReturnType<\n\ttypeof import('./proto/sui/rpc/v2/executed_transaction.js').ExecutedTransaction.toJson\n>;\n\nexport type GrpcSimulateTransactionProtoJson = ReturnType<\n\ttypeof import('./proto/sui/rpc/v2/transaction_execution_service.js').SimulateTransactionResponse.toJson\n>;\n\ntype ProtoJson<Include extends { protoJson?: boolean }, Json> = Include['protoJson'] extends true\n\t? Json\n\t: undefined;\n\nexport type GrpcTransactionResult<Include extends GrpcTransactionInclude = {}> =\n\tSuiClientTypes.TransactionResult<Include> & {\n\t\tprotoJson: ProtoJson<Include, GrpcTransactionProtoJson>;\n\t};\n\nexport type GrpcSimulateTransactionResult<Include extends GrpcSimulateTransactionInclude = {}> =\n\tSuiClientTypes.SimulateTransactionResult<Include> & {\n\t\tprotoJson: ProtoJson<Include, GrpcSimulateTransactionProtoJson>;\n\t};\n\nexport interface GrpcGetTransactionOptions<\n\tInclude extends GrpcTransactionInclude = {},\n> extends SuiClientTypes.GetTransactionOptions<Include> {\n\tinclude?: Include & GrpcTransactionInclude;\n}\n\nexport interface GrpcWaitForTransactionByDigest<\n\tInclude extends GrpcTransactionInclude = {},\n> extends SuiClientTypes.WaitForTransactionByDigest<Include> {\n\tinclude?: Include & GrpcTransactionInclude;\n}\n\nexport interface GrpcWaitForTransactionByResult<\n\tInclude extends GrpcTransactionInclude = {},\n> extends SuiClientTypes.WaitForTransactionByResult<Include> {\n\tinclude?: Include & GrpcTransactionInclude;\n}\n\nexport type GrpcWaitForTransactionOptions<Include extends GrpcTransactionInclude = {}> =\n\tGrpcWaitForTransactionByDigest<Include> | GrpcWaitForTransactionByResult<Include>;\n\nexport interface GrpcExecuteTransactionOptions<\n\tInclude extends GrpcTransactionInclude = {},\n> extends SuiClientTypes.ExecuteTransactionOptions<Include> {\n\tinclude?: Include & GrpcTransactionInclude;\n}\n\nexport interface GrpcSignAndExecuteTransactionOptions<\n\tInclude extends GrpcTransactionInclude = {},\n> extends SuiClientTypes.SignAndExecuteTransactionOptions<Include> {\n\tinclude?: Include & GrpcTransactionInclude;\n}\n\nexport interface GrpcSimulateTransactionOptions<\n\tInclude extends GrpcSimulateTransactionInclude = {},\n> extends SuiClientTypes.SimulateTransactionOptions<Include> {\n\tinclude?: Include & GrpcSimulateTransactionInclude;\n\t/**\n\t * Overrides whether the server selects gas payment during simulation.\n\t *\n\t * When not set, gas selection is enabled only when the transaction's gas payment is explicitly\n\t * set to an empty list (`[]`), which indicates gas is paid from the sender's address balance.\n\t * Transactions with gas coins set are simulated as-is, and transactions without a gas payment\n\t * are simulated with a mocked gas coin.\n\t */\n\tdoGasSelection?: boolean;\n}\n\nexport class SuiGrpcClient extends BaseClient implements SuiClientTypes.TransportMethods {\n\tcore: GrpcCoreClient;\n\tget mvr(): SuiClientTypes.MvrMethods {\n\t\treturn this.core.mvr;\n\t}\n\ttransactionExecutionService: TransactionExecutionServiceClient;\n\tledgerService: LedgerServiceClient;\n\tstateService: StateServiceClient;\n\tsubscriptionService: SubscriptionServiceClient;\n\tmovePackageService: MovePackageServiceClient;\n\tsignatureVerificationService: SignatureVerificationServiceClient;\n\tnameService: NameServiceClient;\n\tforkingService: ForkingServiceClient;\n\n\tget [SUI_CLIENT_BRAND]() {\n\t\treturn true;\n\t}\n\n\tconstructor(options: SuiGrpcClientOptions) {\n\t\tsuper({ network: options.network });\n\t\tconst {\n\t\t\tnetwork: _network,\n\t\t\tmvr: _mvr,\n\t\t\t// Not forwarded: every Core API call passes its own `signal`, which would overwrite it.\n\t\t\tabort: _abort,\n\t\t\ttransport: providedTransport,\n\t\t\t...transportOptions\n\t\t} = options as SuiGrpcClientOptions & SuiGrpcTransportOptions & { transport?: RpcTransport };\n\n\t\t// Add the protocol-version default for every transport, including native gRPC.\n\t\tconst transport = withClientProtocolVersion(\n\t\t\tprovidedTransport ?? new GrpcWebFetchTransport(transportOptions),\n\t\t);\n\t\tthis.transactionExecutionService = new TransactionExecutionServiceClient(transport);\n\t\tthis.ledgerService = new LedgerServiceClient(transport);\n\t\tthis.stateService = new StateServiceClient(transport);\n\t\tthis.subscriptionService = new SubscriptionServiceClient(transport);\n\t\tthis.movePackageService = new MovePackageServiceClient(transport);\n\t\tthis.signatureVerificationService = new SignatureVerificationServiceClient(transport);\n\t\tthis.nameService = new NameServiceClient(transport);\n\t\tthis.forkingService = new ForkingServiceClient(transport);\n\n\t\tthis.core = new GrpcCoreClient({\n\t\t\tclient: this,\n\t\t\tbase: this,\n\t\t\tnetwork: options.network,\n\t\t\tmvr: options.mvr,\n\t\t});\n\t}\n\n\tgetObjects<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetObjectsOptions<Include>,\n\t): Promise<SuiClientTypes.GetObjectsResponse<Include>> {\n\t\treturn this.core.getObjects(input);\n\t}\n\n\tgetObject<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetObjectOptions<Include>,\n\t): Promise<SuiClientTypes.GetObjectResponse<Include>> {\n\t\treturn this.core.getObject(input);\n\t}\n\n\tlistCoins(input: SuiClientTypes.ListCoinsOptions): Promise<SuiClientTypes.ListCoinsResponse> {\n\t\treturn this.core.listCoins(input);\n\t}\n\n\tlistOwnedObjects<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.ListOwnedObjectsOptions<Include>,\n\t): Promise<SuiClientTypes.ListOwnedObjectsResponse<Include>> {\n\t\treturn this.core.listOwnedObjects(input);\n\t}\n\n\tgetBalance(input: SuiClientTypes.GetBalanceOptions): Promise<SuiClientTypes.GetBalanceResponse> {\n\t\treturn this.core.getBalance(input);\n\t}\n\n\tlistBalances(\n\t\tinput: SuiClientTypes.ListBalancesOptions,\n\t): Promise<SuiClientTypes.ListBalancesResponse> {\n\t\treturn this.core.listBalances(input);\n\t}\n\n\tgetCoinMetadata(\n\t\tinput: SuiClientTypes.GetCoinMetadataOptions,\n\t): Promise<SuiClientTypes.GetCoinMetadataResponse> {\n\t\treturn this.core.getCoinMetadata(input);\n\t}\n\n\tgetTransaction<Include extends GrpcTransactionInclude = {}>(\n\t\tinput: GrpcGetTransactionOptions<Include>,\n\t): Promise<GrpcTransactionResult<Include>> {\n\t\treturn this.core.getTransaction(input) as Promise<GrpcTransactionResult<Include>>;\n\t}\n\n\texecuteTransaction<Include extends GrpcTransactionInclude = {}>(\n\t\tinput: GrpcExecuteTransactionOptions<Include>,\n\t): Promise<GrpcTransactionResult<Include>> {\n\t\treturn this.core.executeTransaction(input) as Promise<GrpcTransactionResult<Include>>;\n\t}\n\n\tsignAndExecuteTransaction<Include extends GrpcTransactionInclude = {}>(\n\t\tinput: GrpcSignAndExecuteTransactionOptions<Include>,\n\t): Promise<GrpcTransactionResult<Include>> {\n\t\treturn this.core.signAndExecuteTransaction(input) as Promise<GrpcTransactionResult<Include>>;\n\t}\n\n\twaitForTransaction<Include extends GrpcTransactionInclude = {}>(\n\t\tinput: GrpcWaitForTransactionOptions<Include>,\n\t): Promise<GrpcTransactionResult<Include>> {\n\t\treturn this.core.waitForTransaction(input) as Promise<GrpcTransactionResult<Include>>;\n\t}\n\n\tsimulateTransaction<Include extends GrpcSimulateTransactionInclude = {}>(\n\t\tinput: GrpcSimulateTransactionOptions<Include>,\n\t): Promise<GrpcSimulateTransactionResult<Include>> {\n\t\treturn this.core.simulateTransaction(input) as Promise<GrpcSimulateTransactionResult<Include>>;\n\t}\n\n\tgetReferenceGasPrice(\n\t\tinput?: SuiClientTypes.GetReferenceGasPriceOptions,\n\t): Promise<SuiClientTypes.GetReferenceGasPriceResponse> {\n\t\treturn this.core.getReferenceGasPrice(input);\n\t}\n\n\tgetCurrentSystemState(\n\t\tinput?: SuiClientTypes.GetCurrentSystemStateOptions,\n\t): Promise<SuiClientTypes.GetCurrentSystemStateResponse> {\n\t\treturn this.core.getCurrentSystemState(input);\n\t}\n\n\tgetProtocolConfig(\n\t\tinput?: SuiClientTypes.GetProtocolConfigOptions,\n\t): Promise<SuiClientTypes.GetProtocolConfigResponse> {\n\t\treturn this.core.getProtocolConfig(input);\n\t}\n\n\tgetChainIdentifier(\n\t\tinput?: SuiClientTypes.GetChainIdentifierOptions,\n\t): Promise<SuiClientTypes.GetChainIdentifierResponse> {\n\t\treturn this.core.getChainIdentifier(input);\n\t}\n\n\tasync listDynamicFields<Include extends DynamicFieldInclude = {}>(\n\t\tinput: SuiClientTypes.ListDynamicFieldsOptions & { include?: Include & DynamicFieldInclude },\n\t): Promise<ListDynamicFieldsWithValueResponse<Include>> {\n\t\tconst includeValue = input.include?.value ?? false;\n\t\tconst paths = ['field_id', 'name', 'value_type', 'kind', 'child_id'];\n\t\tif (includeValue) {\n\t\t\tpaths.push('value');\n\t\t}\n\n\t\tconst response = await this.stateService.listDynamicFields(\n\t\t\t{\n\t\t\t\tparent: input.parentId,\n\t\t\t\tpageToken: input.cursor ? fromBase64(input.cursor) : undefined,\n\t\t\t\tpageSize: input.limit,\n\t\t\t\treadMask: {\n\t\t\t\t\tpaths,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ abort: input.signal },\n\t\t);\n\n\t\treturn {\n\t\t\tdynamicFields: response.response.dynamicFields.map(\n\t\t\t\t(field): DynamicFieldEntryWithValue<Include> => {\n\t\t\t\t\tconst isDynamicObject = field.kind === DynamicField_DynamicFieldKind.OBJECT;\n\t\t\t\t\tconst fieldType = isDynamicObject\n\t\t\t\t\t\t? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${field.name?.name!}>,0x2::object::ID>`\n\t\t\t\t\t\t: `0x2::dynamic_field::Field<${field.name?.name!},${field.valueType!}>`;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',\n\t\t\t\t\t\tfieldId: field.fieldId!,\n\t\t\t\t\t\tname: {\n\t\t\t\t\t\t\ttype: field.name?.name!,\n\t\t\t\t\t\t\tbcs: field.name?.value!,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalueType: field.valueType!,\n\t\t\t\t\t\ttype: normalizeStructTag(fieldType),\n\t\t\t\t\t\tchildId: field.childId,\n\t\t\t\t\t\tvalue: (includeValue\n\t\t\t\t\t\t\t? { type: field.valueType!, bcs: field.value?.value ?? new Uint8Array() }\n\t\t\t\t\t\t\t: undefined) as DynamicFieldEntryWithValue<Include>['value'],\n\t\t\t\t\t} as DynamicFieldEntryWithValue<Include>;\n\t\t\t\t},\n\t\t\t),\n\t\t\tcursor: response.response.nextPageToken ? toBase64(response.response.nextPageToken) : null,\n\t\t\thasNextPage: response.response.nextPageToken !== undefined,\n\t\t};\n\t}\n\n\tgetDynamicField(\n\t\tinput: SuiClientTypes.GetDynamicFieldOptions,\n\t): Promise<SuiClientTypes.GetDynamicFieldResponse> {\n\t\treturn this.core.getDynamicField(input);\n\t}\n\n\tgetDynamicObjectField<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetDynamicObjectFieldOptions<Include>,\n\t): Promise<SuiClientTypes.GetDynamicObjectFieldResponse<Include>> {\n\t\treturn this.core.getDynamicObjectField(input);\n\t}\n\n\tlistTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.ListTransactionsOptions<Include>,\n\t): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {\n\t\treturn this.core.listTransactions(input);\n\t}\n\n\tlistEvents(input: SuiClientTypes.ListEventsOptions): Promise<SuiClientTypes.ListEventsResponse> {\n\t\treturn this.core.listEvents(input);\n\t}\n\n\tgetMoveFunction(\n\t\tinput: SuiClientTypes.GetMoveFunctionOptions,\n\t): Promise<SuiClientTypes.GetMoveFunctionResponse> {\n\t\treturn this.core.getMoveFunction(input);\n\t}\n\n\tresolveTransactionPlugin(): TransactionPlugin {\n\t\treturn this.core.resolveTransactionPlugin();\n\t}\n\n\tverifyZkLoginSignature(\n\t\tinput: SuiClientTypes.VerifyZkLoginSignatureOptions,\n\t): Promise<SuiClientTypes.ZkLoginVerifyResponse> {\n\t\treturn this.core.verifyZkLoginSignature(input);\n\t}\n\n\tdefaultNameServiceName(\n\t\tinput: SuiClientTypes.DefaultNameServiceNameOptions,\n\t): Promise<SuiClientTypes.DefaultNameServiceNameResponse> {\n\t\treturn this.core.defaultNameServiceName(input);\n\t}\n\n\tresolveNameServiceAddress(\n\t\tinput: SuiClientTypes.ResolveNameServiceAddressOptions,\n\t): Promise<SuiClientTypes.ResolveNameServiceAddressResponse> {\n\t\treturn this.core.resolveNameServiceAddress(input);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,MAAM,mBAAmB,OAAO,IAAI,wBAAwB;AAE5D,SAAgB,gBAAgB,QAA0C;AACzE,QACC,OAAO,WAAW,YAAY,WAAW,QAAS,OAAe,sBAAsB;;AAmGzF,IAAa,gBAAb,cAAmC,WAAsD;CAExF,IAAI,MAAiC;AACpC,SAAO,KAAK,KAAK;;CAWlB,KAAK,oBAAoB;AACxB,SAAO;;CAGR,YAAY,SAA+B;AAC1C,QAAM,EAAE,SAAS,QAAQ,SAAS,CAAC;EACnC,MAAM,EACL,SAAS,UACT,KAAK,MAEL,OAAO,QACP,WAAW,mBACX,GAAG,qBACA;EAGJ,MAAM,YAAY,0BACjB,qBAAqB,IAAI,sBAAsB,iBAAiB,CAChE;AACD,OAAK,8BAA8B,IAAI,kCAAkC,UAAU;AACnF,OAAK,gBAAgB,IAAI,oBAAoB,UAAU;AACvD,OAAK,eAAe,IAAI,mBAAmB,UAAU;AACrD,OAAK,sBAAsB,IAAI,0BAA0B,UAAU;AACnE,OAAK,qBAAqB,IAAI,yBAAyB,UAAU;AACjE,OAAK,+BAA+B,IAAI,mCAAmC,UAAU;AACrF,OAAK,cAAc,IAAI,kBAAkB,UAAU;AACnD,OAAK,iBAAiB,IAAI,qBAAqB,UAAU;AAEzD,OAAK,OAAO,IAAI,eAAe;GAC9B,QAAQ;GACR,MAAM;GACN,SAAS,QAAQ;GACjB,KAAK,QAAQ;GACb,CAAC;;CAGH,WACC,OACsD;AACtD,SAAO,KAAK,KAAK,WAAW,MAAM;;CAGnC,UACC,OACqD;AACrD,SAAO,KAAK,KAAK,UAAU,MAAM;;CAGlC,UAAU,OAAmF;AAC5F,SAAO,KAAK,KAAK,UAAU,MAAM;;CAGlC,iBACC,OAC4D;AAC5D,SAAO,KAAK,KAAK,iBAAiB,MAAM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AM,KAAM,GAAG,MAAM,UAAW;AACtE,WAAO;KACN,OAAO,kBAAkB,kBAAkB;KAC3C,SAAS,MAAM;KACf,MAAM;MACL,MAAM,MAAM,MAAM;MAClB,KAAK,MAAM,MAAM;MACjB;KACD,WAAW,MAAM;KACjB,MAAM,mBAAmB,UAAU;KACnC,SAAS,MAAM;KACf,OAAQ,eACL;MAAE,MAAM,MAAM;MAAY,KAAK,MAAM,OAAO,SAAS,IAAI,YAAY;MAAE,GACvE;KACH;KAEF;GACD,QAAQ,SAAS,SAAS,gBAAgB,SAAS,SAAS,SAAS,cAAc,GAAG;GACtF,aAAa,SAAS,SAAS,kBAAkB;GACjD;;CAGF,gBACC,OACkD;AAClD,SAAO,KAAK,KAAK,gBAAgB,MAAM;;CAGxC,sBACC,OACiE;AACjE,SAAO,KAAK,KAAK,sBAAsB,MAAM;;CAG9C,iBACC,OAC4D;AAC5D,SAAO,KAAK,KAAK,iBAAiB,MAAM;;CAGzC,WAAW,OAAqF;AAC/F,SAAO,KAAK,KAAK,WAAW,MAAM;;CAGnC,gBACC,OACkD;AAClD,SAAO,KAAK,KAAK,gBAAgB,MAAM;;CAGxC,2BAA8C;AAC7C,SAAO,KAAK,KAAK,0BAA0B;;CAG5C,uBACC,OACgD;AAChD,SAAO,KAAK,KAAK,uBAAuB,MAAM;;CAG/C,uBACC,OACyD;AACzD,SAAO,KAAK,KAAK,uBAAuB,MAAM;;CAG/C,0BACC,OAC4D;AAC5D,SAAO,KAAK,KAAK,0BAA0B,MAAM"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AdvanceCheckpointRequest, AdvanceCheckpointResponse, AdvanceClockRequest, AdvanceClockResponse, GetStatusRequest, GetStatusResponse } from "./forking_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime6 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc6 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/forking/v1alpha/forking_service.client.d.ts
|
|
@@ -37,9 +37,9 @@ interface IForkingServiceClient {
|
|
|
37
37
|
declare class ForkingServiceClient implements IForkingServiceClient, ServiceInfo {
|
|
38
38
|
private readonly _transport;
|
|
39
39
|
typeName: string;
|
|
40
|
-
methods:
|
|
40
|
+
methods: _protobuf_ts_runtime_rpc6.MethodInfo<any, any>[];
|
|
41
41
|
options: {
|
|
42
|
-
[extensionName: string]:
|
|
42
|
+
[extensionName: string]: _protobuf_ts_runtime6.JsonValue;
|
|
43
43
|
};
|
|
44
44
|
constructor(_transport: RpcTransport);
|
|
45
45
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BatchGetObjectsRequest, BatchGetObjectsResponse, BatchGetTransactionsRequest, BatchGetTransactionsResponse, GetCheckpointRequest, GetCheckpointResponse, GetEpochRequest, GetEpochResponse, GetObjectRequest, GetObjectResponse, GetServiceInfoRequest, GetServiceInfoResponse, GetTransactionRequest, GetTransactionResponse, ListCheckpointsRequest, ListCheckpointsResponse, ListEventsRequest, ListEventsResponse, ListTransactionsRequest, ListTransactionsResponse } from "./ledger_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime0 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc0 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServerStreamingCall, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/ledger_service.client.d.ts
|
|
@@ -73,9 +73,9 @@ interface ILedgerServiceClient {
|
|
|
73
73
|
declare class LedgerServiceClient implements ILedgerServiceClient, ServiceInfo {
|
|
74
74
|
private readonly _transport;
|
|
75
75
|
typeName: string;
|
|
76
|
-
methods:
|
|
76
|
+
methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
|
|
77
77
|
options: {
|
|
78
|
-
[extensionName: string]:
|
|
78
|
+
[extensionName: string]: _protobuf_ts_runtime0.JsonValue;
|
|
79
79
|
};
|
|
80
80
|
constructor(_transport: RpcTransport);
|
|
81
81
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LookupNameRequest, LookupNameResponse, ReverseLookupNameRequest, ReverseLookupNameResponse } from "./name_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime5 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc5 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/name_service.client.d.ts
|
|
@@ -23,9 +23,9 @@ interface INameServiceClient {
|
|
|
23
23
|
declare class NameServiceClient implements INameServiceClient, ServiceInfo {
|
|
24
24
|
private readonly _transport;
|
|
25
25
|
typeName: string;
|
|
26
|
-
methods:
|
|
26
|
+
methods: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
|
|
27
27
|
options: {
|
|
28
|
-
[extensionName: string]:
|
|
28
|
+
[extensionName: string]: _protobuf_ts_runtime5.JsonValue;
|
|
29
29
|
};
|
|
30
30
|
constructor(_transport: RpcTransport);
|
|
31
31
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VerifySignatureRequest, VerifySignatureResponse } from "./signature_verification_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime1 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc1 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.ts
|
|
@@ -21,9 +21,9 @@ interface ISignatureVerificationServiceClient {
|
|
|
21
21
|
declare class SignatureVerificationServiceClient implements ISignatureVerificationServiceClient, ServiceInfo {
|
|
22
22
|
private readonly _transport;
|
|
23
23
|
typeName: string;
|
|
24
|
-
methods:
|
|
24
|
+
methods: _protobuf_ts_runtime_rpc1.MethodInfo<any, any>[];
|
|
25
25
|
options: {
|
|
26
|
-
[extensionName: string]:
|
|
26
|
+
[extensionName: string]: _protobuf_ts_runtime1.JsonValue;
|
|
27
27
|
};
|
|
28
28
|
constructor(_transport: RpcTransport);
|
|
29
29
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetBalanceRequest, GetBalanceResponse, GetCoinInfoRequest, GetCoinInfoResponse, ListBalancesRequest, ListBalancesResponse, ListDynamicFieldsRequest, ListDynamicFieldsResponse, ListOwnedObjectsRequest, ListOwnedObjectsResponse } from "./state_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime3 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc3 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/state_service.client.d.ts
|
|
@@ -35,9 +35,9 @@ interface IStateServiceClient {
|
|
|
35
35
|
declare class StateServiceClient implements IStateServiceClient, ServiceInfo {
|
|
36
36
|
private readonly _transport;
|
|
37
37
|
typeName: string;
|
|
38
|
-
methods:
|
|
38
|
+
methods: _protobuf_ts_runtime_rpc3.MethodInfo<any, any>[];
|
|
39
39
|
options: {
|
|
40
|
-
[extensionName: string]:
|
|
40
|
+
[extensionName: string]: _protobuf_ts_runtime3.JsonValue;
|
|
41
41
|
};
|
|
42
42
|
constructor(_transport: RpcTransport);
|
|
43
43
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SubscribeCheckpointsRequest, SubscribeCheckpointsResponse, SubscribeEventsRequest, SubscribeEventsResponse, SubscribeTransactionsRequest, SubscribeTransactionsResponse } from "./subscription_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime4 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc4 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServerStreamingCall, ServiceInfo } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts
|
|
@@ -100,9 +100,9 @@ interface ISubscriptionServiceClient {
|
|
|
100
100
|
declare class SubscriptionServiceClient implements ISubscriptionServiceClient, ServiceInfo {
|
|
101
101
|
private readonly _transport;
|
|
102
102
|
typeName: string;
|
|
103
|
-
methods:
|
|
103
|
+
methods: _protobuf_ts_runtime_rpc4.MethodInfo<any, any>[];
|
|
104
104
|
options: {
|
|
105
|
-
[extensionName: string]:
|
|
105
|
+
[extensionName: string]: _protobuf_ts_runtime4.JsonValue;
|
|
106
106
|
};
|
|
107
107
|
constructor(_transport: RpcTransport);
|
|
108
108
|
/**
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { MethodInfo, RpcOptions, ServerStreamingCall, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
2
|
-
import { GrpcWebFetchTransport } from "@protobuf-ts/grpcweb-transport";
|
|
1
|
+
import { MethodInfo, RpcOptions, RpcTransport, ServerStreamingCall, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
2
|
+
import { GrpcWebFetchTransport, GrpcWebOptions } from "@protobuf-ts/grpcweb-transport";
|
|
3
3
|
|
|
4
4
|
//#region src/grpc/transport.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* `GrpcWebFetchTransport` from `@protobuf-ts/grpcweb-transport`, subclassed to decode status
|
|
7
|
-
* messages
|
|
7
|
+
* messages, to code an aborted call from its reason rather than as `INTERNAL`, and to send the
|
|
8
|
+
* `x-sui-client-protocol-version` header.
|
|
8
9
|
*
|
|
9
10
|
* `SuiGrpcClient` builds one by default. A transport imported from `@protobuf-ts/grpcweb-transport`
|
|
10
11
|
* keeps that package's behaviour.
|
|
11
12
|
*/
|
|
12
13
|
declare class GrpcWebFetchTransport$1 extends GrpcWebFetchTransport {
|
|
14
|
+
constructor(options: GrpcWebOptions);
|
|
13
15
|
unary<I extends object, O extends object>(method: MethodInfo<I, O>, input: I, options: RpcOptions): UnaryCall<I, O>;
|
|
14
16
|
serverStreaming<I extends object, O extends object>(method: MethodInfo<I, O>, input: I, options: RpcOptions): ServerStreamingCall<I, O>;
|
|
15
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.mts","names":[],"sources":["../../src/grpc/transport.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"transport.d.mts","names":[],"sources":["../../src/grpc/transport.ts"],"mappings":";;;;;;;;;;;;cA6Ia,uBAAA,SAA8B,qBAAA;cAC9B,OAAA,EAAS,cAAA;EAWZ,KAAA,oCAAA,CACR,MAAA,EAAQ,UAAA,CAAW,CAAA,EAAG,CAAA,GACtB,KAAA,EAAO,CAAA,EACP,OAAA,EAAS,UAAA,GACP,SAAA,CAAU,CAAA,EAAG,CAAA;EAQP,eAAA,oCAAA,CACR,MAAA,EAAQ,UAAA,CAAW,CAAA,EAAG,CAAA,GACtB,KAAA,EAAO,CAAA,EACP,OAAA,EAAS,UAAA,GACP,mBAAA,CAAoB,CAAA,EAAG,CAAA;AAAA"}
|
package/dist/grpc/transport.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CLIENT_PROTOCOL_VERSION_HEADER, MAX_PROTOCOL_VERSION } from "../client/protocol-version.mjs";
|
|
1
2
|
import { RpcError } from "@protobuf-ts/runtime-rpc";
|
|
2
3
|
import { GrpcStatusCode, GrpcWebFetchTransport } from "@protobuf-ts/grpcweb-transport";
|
|
3
4
|
|
|
@@ -64,12 +65,22 @@ function normalizeRejections(promises, signal) {
|
|
|
64
65
|
}
|
|
65
66
|
/**
|
|
66
67
|
* `GrpcWebFetchTransport` from `@protobuf-ts/grpcweb-transport`, subclassed to decode status
|
|
67
|
-
* messages
|
|
68
|
+
* messages, to code an aborted call from its reason rather than as `INTERNAL`, and to send the
|
|
69
|
+
* `x-sui-client-protocol-version` header.
|
|
68
70
|
*
|
|
69
71
|
* `SuiGrpcClient` builds one by default. A transport imported from `@protobuf-ts/grpcweb-transport`
|
|
70
72
|
* keeps that package's behaviour.
|
|
71
73
|
*/
|
|
72
74
|
var GrpcWebFetchTransport$1 = class extends GrpcWebFetchTransport {
|
|
75
|
+
constructor(options) {
|
|
76
|
+
super({
|
|
77
|
+
...options,
|
|
78
|
+
meta: {
|
|
79
|
+
[CLIENT_PROTOCOL_VERSION_HEADER]: String(MAX_PROTOCOL_VERSION),
|
|
80
|
+
...options.meta
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
73
84
|
unary(method, input, options) {
|
|
74
85
|
const call = super.unary(method, input, options);
|
|
75
86
|
normalizeRejections([
|
|
@@ -91,7 +102,26 @@ var GrpcWebFetchTransport$1 = class extends GrpcWebFetchTransport {
|
|
|
91
102
|
return call;
|
|
92
103
|
}
|
|
93
104
|
};
|
|
105
|
+
/** Adds SDK metadata without mutating the caller's transport or its default options. */
|
|
106
|
+
function withClientProtocolVersion(transport) {
|
|
107
|
+
return {
|
|
108
|
+
mergeOptions(options) {
|
|
109
|
+
const merged = transport.mergeOptions(options);
|
|
110
|
+
return {
|
|
111
|
+
...merged,
|
|
112
|
+
meta: {
|
|
113
|
+
[CLIENT_PROTOCOL_VERSION_HEADER]: String(MAX_PROTOCOL_VERSION),
|
|
114
|
+
...merged.meta
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
unary: transport.unary.bind(transport),
|
|
119
|
+
serverStreaming: transport.serverStreaming.bind(transport),
|
|
120
|
+
clientStreaming: transport.clientStreaming.bind(transport),
|
|
121
|
+
duplex: transport.duplex.bind(transport)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
94
124
|
|
|
95
125
|
//#endregion
|
|
96
|
-
export { GrpcWebFetchTransport$1 as GrpcWebFetchTransport, hasDecodedStatusMessage };
|
|
126
|
+
export { GrpcWebFetchTransport$1 as GrpcWebFetchTransport, hasDecodedStatusMessage, withClientProtocolVersion };
|
|
97
127
|
//# sourceMappingURL=transport.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.mjs","names":["GrpcWebFetchTransport","UpstreamGrpcWebFetchTransport"],"sources":["../../src/grpc/transport.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { GrpcStatusCode } from '@protobuf-ts/grpcweb-transport';\nimport { GrpcWebFetchTransport as UpstreamGrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport';\nimport type {\n\tMethodInfo,\n\tRpcOptions,\n\tServerStreamingCall,\n\tUnaryCall,\n} from '@protobuf-ts/runtime-rpc';\nimport { RpcError } from '@protobuf-ts/runtime-rpc';\n\n// A failed call rejects four promises with the same error, so it is only decoded once. Registered\n// globally so another installed copy of this package sees the same marker.\nconst MESSAGE_DECODED = Symbol.for('@mysten/sui/grpc/decoded-status-message');\n\n// `grpc-message` is percent-encoded on the wire and the upstream transport does not decode it:\n// https://github.com/timostamm/protobuf-ts/pull/739\nfunction decodeGrpcStatusMessage(message: string): string {\n\tif (!message.includes('%')) return message;\n\n\ttry {\n\t\treturn decodeURIComponent(message);\n\t} catch {\n\t\treturn message;\n\t}\n}\n\nfunction markStatusMessageRead(error: RpcError): boolean {\n\tif (MESSAGE_DECODED in error) return false;\n\tObject.defineProperty(error, MESSAGE_DECODED, { value: true, configurable: true });\n\n\treturn true;\n}\n\nfunction decodeStatusMessageOnce(error: RpcError): void {\n\tif (markStatusMessageRead(error)) error.message = decodeGrpcStatusMessage(error.message);\n}\n\n/** Whether this package's transport decoded the error's status text. */\nexport function hasDecodedStatusMessage(error: object): boolean {\n\treturn MESSAGE_DECODED in error;\n}\n\n// An abort reason is arbitrary, and reading a property on it runs code the caller wrote. A read\n// that throws counts as absent, so one bad accessor does not decide the status.\nfunction readProperty(value: unknown, key: 'code' | 'name' | 'message'): unknown {\n\tif (typeof value !== 'object' || value === null) return undefined;\n\n\ttry {\n\t\treturn (value as Record<string, unknown>)[key];\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n// The reason is read by shape, since another copy of runtime-rpc or another realm fails\n// `instanceof`. `AbortSignal.timeout` aborts with a `TimeoutError`.\nfunction abortStatus(reason: unknown): string {\n\tconst code = readProperty(reason, 'code');\n\n\t// A status name maps to a number; `in` would also match the enum's reverse mapping.\n\tif (\n\t\ttypeof code === 'string' &&\n\t\ttypeof GrpcStatusCode[code as keyof typeof GrpcStatusCode] === 'number'\n\t) {\n\t\treturn code;\n\t}\n\n\treturn readProperty(reason, 'name') === 'TimeoutError'\n\t\t? GrpcStatusCode[GrpcStatusCode.DEADLINE_EXCEEDED]\n\t\t: GrpcStatusCode[GrpcStatusCode.CANCELLED];\n}\n\n// The transport reuses the abort reason's message, so matching it says the text is local. A fetch\n// that substitutes its own error (node-fetch) gives text of its own, which holds nothing to decode.\n// The reason is never coerced: a symbol or a throwing hook would throw here.\nfunction isAbortReasonText(message: string, reason: unknown): boolean {\n\tif (typeof reason === 'string') return message === reason;\n\n\tconst reasonMessage = readProperty(reason, 'message');\n\n\treturn typeof reasonMessage === 'string' && message === reasonMessage;\n}\n\n// Rewritten in place, so every promise a call rejects surfaces the same error. Only the two codes\n// upstream uses for an abort are re-coded; a failure that raced the abort is relabelled with it.\nfunction normalizeGrpcError(error: unknown, signal: AbortSignal | undefined): void {\n\ttry {\n\t\tnormalize(error, signal);\n\t} catch {\n\t\t// Never an unhandled rejection from a discarded handler: the call reports what it was going\n\t\t// to report.\n\t}\n}\n\nfunction normalize(error: unknown, signal: AbortSignal | undefined): void {\n\tif (!(error instanceof RpcError)) return;\n\n\tif (\n\t\tsignal?.aborted &&\n\t\t(error.code === GrpcStatusCode[GrpcStatusCode.INTERNAL] ||\n\t\t\terror.code === GrpcStatusCode[GrpcStatusCode.CANCELLED])\n\t) {\n\t\terror.code = abortStatus(signal.reason);\n\n\t\t// Text the abort reason supplied is local and holds nothing to decode; anything else came off\n\t\t// the wire, even though the abort is what the caller sees. Settled here for the other promises\n\t\t// the call rejects, which no longer match the codes above.\n\t\tif (isAbortReasonText(error.message, signal.reason)) markStatusMessageRead(error);\n\t\telse decodeStatusMessageOnce(error);\n\n\t\treturn;\n\t}\n\n\tdecodeStatusMessageOnce(error);\n}\n\nfunction normalizeRejections(promises: Promise<unknown>[], signal: AbortSignal | undefined) {\n\tfor (const promise of promises) {\n\t\t// Registered before the call is returned, so it runs before the consumer's own await.\n\t\tpromise.then(undefined, (error: unknown) => normalizeGrpcError(error, signal));\n\t}\n}\n\n/**\n * `GrpcWebFetchTransport` from `@protobuf-ts/grpcweb-transport`, subclassed to decode status\n * messages
|
|
1
|
+
{"version":3,"file":"transport.mjs","names":["GrpcWebFetchTransport","UpstreamGrpcWebFetchTransport"],"sources":["../../src/grpc/transport.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { GrpcWebOptions } from '@protobuf-ts/grpcweb-transport';\nimport { GrpcStatusCode } from '@protobuf-ts/grpcweb-transport';\nimport { GrpcWebFetchTransport as UpstreamGrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport';\nimport type {\n\tMethodInfo,\n\tRpcOptions,\n\tRpcTransport,\n\tServerStreamingCall,\n\tUnaryCall,\n} from '@protobuf-ts/runtime-rpc';\nimport { RpcError } from '@protobuf-ts/runtime-rpc';\n\nimport {\n\tCLIENT_PROTOCOL_VERSION_HEADER,\n\tMAX_PROTOCOL_VERSION,\n} from '../client/protocol-version.js';\n\n// A failed call rejects four promises with the same error, so it is only decoded once. Registered\n// globally so another installed copy of this package sees the same marker.\nconst MESSAGE_DECODED = Symbol.for('@mysten/sui/grpc/decoded-status-message');\n\n// `grpc-message` is percent-encoded on the wire and the upstream transport does not decode it:\n// https://github.com/timostamm/protobuf-ts/pull/739\nfunction decodeGrpcStatusMessage(message: string): string {\n\tif (!message.includes('%')) return message;\n\n\ttry {\n\t\treturn decodeURIComponent(message);\n\t} catch {\n\t\treturn message;\n\t}\n}\n\nfunction markStatusMessageRead(error: RpcError): boolean {\n\tif (MESSAGE_DECODED in error) return false;\n\tObject.defineProperty(error, MESSAGE_DECODED, { value: true, configurable: true });\n\n\treturn true;\n}\n\nfunction decodeStatusMessageOnce(error: RpcError): void {\n\tif (markStatusMessageRead(error)) error.message = decodeGrpcStatusMessage(error.message);\n}\n\n/** Whether this package's transport decoded the error's status text. */\nexport function hasDecodedStatusMessage(error: object): boolean {\n\treturn MESSAGE_DECODED in error;\n}\n\n// An abort reason is arbitrary, and reading a property on it runs code the caller wrote. A read\n// that throws counts as absent, so one bad accessor does not decide the status.\nfunction readProperty(value: unknown, key: 'code' | 'name' | 'message'): unknown {\n\tif (typeof value !== 'object' || value === null) return undefined;\n\n\ttry {\n\t\treturn (value as Record<string, unknown>)[key];\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n// The reason is read by shape, since another copy of runtime-rpc or another realm fails\n// `instanceof`. `AbortSignal.timeout` aborts with a `TimeoutError`.\nfunction abortStatus(reason: unknown): string {\n\tconst code = readProperty(reason, 'code');\n\n\t// A status name maps to a number; `in` would also match the enum's reverse mapping.\n\tif (\n\t\ttypeof code === 'string' &&\n\t\ttypeof GrpcStatusCode[code as keyof typeof GrpcStatusCode] === 'number'\n\t) {\n\t\treturn code;\n\t}\n\n\treturn readProperty(reason, 'name') === 'TimeoutError'\n\t\t? GrpcStatusCode[GrpcStatusCode.DEADLINE_EXCEEDED]\n\t\t: GrpcStatusCode[GrpcStatusCode.CANCELLED];\n}\n\n// The transport reuses the abort reason's message, so matching it says the text is local. A fetch\n// that substitutes its own error (node-fetch) gives text of its own, which holds nothing to decode.\n// The reason is never coerced: a symbol or a throwing hook would throw here.\nfunction isAbortReasonText(message: string, reason: unknown): boolean {\n\tif (typeof reason === 'string') return message === reason;\n\n\tconst reasonMessage = readProperty(reason, 'message');\n\n\treturn typeof reasonMessage === 'string' && message === reasonMessage;\n}\n\n// Rewritten in place, so every promise a call rejects surfaces the same error. Only the two codes\n// upstream uses for an abort are re-coded; a failure that raced the abort is relabelled with it.\nfunction normalizeGrpcError(error: unknown, signal: AbortSignal | undefined): void {\n\ttry {\n\t\tnormalize(error, signal);\n\t} catch {\n\t\t// Never an unhandled rejection from a discarded handler: the call reports what it was going\n\t\t// to report.\n\t}\n}\n\nfunction normalize(error: unknown, signal: AbortSignal | undefined): void {\n\tif (!(error instanceof RpcError)) return;\n\n\tif (\n\t\tsignal?.aborted &&\n\t\t(error.code === GrpcStatusCode[GrpcStatusCode.INTERNAL] ||\n\t\t\terror.code === GrpcStatusCode[GrpcStatusCode.CANCELLED])\n\t) {\n\t\terror.code = abortStatus(signal.reason);\n\n\t\t// Text the abort reason supplied is local and holds nothing to decode; anything else came off\n\t\t// the wire, even though the abort is what the caller sees. Settled here for the other promises\n\t\t// the call rejects, which no longer match the codes above.\n\t\tif (isAbortReasonText(error.message, signal.reason)) markStatusMessageRead(error);\n\t\telse decodeStatusMessageOnce(error);\n\n\t\treturn;\n\t}\n\n\tdecodeStatusMessageOnce(error);\n}\n\nfunction normalizeRejections(promises: Promise<unknown>[], signal: AbortSignal | undefined) {\n\tfor (const promise of promises) {\n\t\t// Registered before the call is returned, so it runs before the consumer's own await.\n\t\tpromise.then(undefined, (error: unknown) => normalizeGrpcError(error, signal));\n\t}\n}\n\n/**\n * `GrpcWebFetchTransport` from `@protobuf-ts/grpcweb-transport`, subclassed to decode status\n * messages, to code an aborted call from its reason rather than as `INTERNAL`, and to send the\n * `x-sui-client-protocol-version` header.\n *\n * `SuiGrpcClient` builds one by default. A transport imported from `@protobuf-ts/grpcweb-transport`\n * keeps that package's behaviour.\n */\nexport class GrpcWebFetchTransport extends UpstreamGrpcWebFetchTransport {\n\tconstructor(options: GrpcWebOptions) {\n\t\t// Lets the server avoid sending types this SDK cannot decode. Caller-supplied `meta` wins.\n\t\tsuper({\n\t\t\t...options,\n\t\t\tmeta: {\n\t\t\t\t[CLIENT_PROTOCOL_VERSION_HEADER]: String(MAX_PROTOCOL_VERSION),\n\t\t\t\t...options.meta,\n\t\t\t},\n\t\t});\n\t}\n\n\toverride unary<I extends object, O extends object>(\n\t\tmethod: MethodInfo<I, O>,\n\t\tinput: I,\n\t\toptions: RpcOptions,\n\t): UnaryCall<I, O> {\n\t\tconst call = super.unary(method, input, options);\n\n\t\tnormalizeRejections([call.headers, call.response, call.status, call.trailers], options.abort);\n\n\t\treturn call;\n\t}\n\n\toverride serverStreaming<I extends object, O extends object>(\n\t\tmethod: MethodInfo<I, O>,\n\t\tinput: I,\n\t\toptions: RpcOptions,\n\t): ServerStreamingCall<I, O> {\n\t\tconst call = super.serverStreaming(method, input, options);\n\n\t\t// A finite stream is often read through `responses` without awaiting `status`.\n\t\tcall.responses.onError((error) => normalizeGrpcError(error, options.abort));\n\t\tnormalizeRejections([call.headers, call.status, call.trailers], options.abort);\n\n\t\treturn call;\n\t}\n}\n\n/** Adds SDK metadata without mutating the caller's transport or its default options. */\nexport function withClientProtocolVersion(transport: RpcTransport): RpcTransport {\n\treturn {\n\t\tmergeOptions(options) {\n\t\t\tconst merged = transport.mergeOptions(options);\n\t\t\treturn {\n\t\t\t\t...merged,\n\t\t\t\tmeta: {\n\t\t\t\t\t[CLIENT_PROTOCOL_VERSION_HEADER]: String(MAX_PROTOCOL_VERSION),\n\t\t\t\t\t...merged.meta,\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tunary: transport.unary.bind(transport),\n\t\tserverStreaming: transport.serverStreaming.bind(transport),\n\t\tclientStreaming: transport.clientStreaming.bind(transport),\n\t\tduplex: transport.duplex.bind(transport),\n\t};\n}\n"],"mappings":";;;;;AAsBA,MAAM,kBAAkB,OAAO,IAAI,0CAA0C;AAI7E,SAAS,wBAAwB,SAAyB;AACzD,KAAI,CAAC,QAAQ,SAAS,IAAI,CAAE,QAAO;AAEnC,KAAI;AACH,SAAO,mBAAmB,QAAQ;SAC3B;AACP,SAAO;;;AAIT,SAAS,sBAAsB,OAA0B;AACxD,KAAI,mBAAmB,MAAO,QAAO;AACrC,QAAO,eAAe,OAAO,iBAAiB;EAAE,OAAO;EAAM,cAAc;EAAM,CAAC;AAElF,QAAO;;AAGR,SAAS,wBAAwB,OAAuB;AACvD,KAAI,sBAAsB,MAAM,CAAE,OAAM,UAAU,wBAAwB,MAAM,QAAQ;;;AAIzF,SAAgB,wBAAwB,OAAwB;AAC/D,QAAO,mBAAmB;;AAK3B,SAAS,aAAa,OAAgB,KAA2C;AAChF,KAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AAExD,KAAI;AACH,SAAQ,MAAkC;SACnC;AACP;;;AAMF,SAAS,YAAY,QAAyB;CAC7C,MAAM,OAAO,aAAa,QAAQ,OAAO;AAGzC,KACC,OAAO,SAAS,YAChB,OAAO,eAAe,UAAyC,SAE/D,QAAO;AAGR,QAAO,aAAa,QAAQ,OAAO,KAAK,iBACrC,eAAe,eAAe,qBAC9B,eAAe,eAAe;;AAMlC,SAAS,kBAAkB,SAAiB,QAA0B;AACrE,KAAI,OAAO,WAAW,SAAU,QAAO,YAAY;CAEnD,MAAM,gBAAgB,aAAa,QAAQ,UAAU;AAErD,QAAO,OAAO,kBAAkB,YAAY,YAAY;;AAKzD,SAAS,mBAAmB,OAAgB,QAAuC;AAClF,KAAI;AAC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AO;KACV;IACD;;EAEF,OAAO,UAAU,MAAM,KAAK,UAAU;EACtC,iBAAiB,UAAU,gBAAgB,KAAK,UAAU;EAC1D,iBAAiB,UAAU,gBAAgB,KAAK,UAAU;EAC1D,QAAQ,UAAU,OAAO,KAAK,UAAU;EACxC"}
|
|
@@ -130,7 +130,7 @@ declare class Transaction {
|
|
|
130
130
|
chain: string;
|
|
131
131
|
nonce: number;
|
|
132
132
|
};
|
|
133
|
-
}, "
|
|
133
|
+
}, "Epoch" | "None" | "ValidDuring" | "Validity"> | null | undefined;
|
|
134
134
|
gasData: {
|
|
135
135
|
budget: string | number | null;
|
|
136
136
|
price: string | number | null;
|
|
@@ -158,7 +158,7 @@ declare class Transaction {
|
|
|
158
158
|
version: string | number;
|
|
159
159
|
digest: string;
|
|
160
160
|
};
|
|
161
|
-
}, "
|
|
161
|
+
}, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
|
|
162
162
|
Pure: {
|
|
163
163
|
bytes: string;
|
|
164
164
|
};
|
|
@@ -190,7 +190,7 @@ declare class Transaction {
|
|
|
190
190
|
};
|
|
191
191
|
}, "Sender" | "Sponsor" | "SenderAllowance">;
|
|
192
192
|
};
|
|
193
|
-
}, "
|
|
193
|
+
}, "Object" | "Pure" | "FundsWithdrawal" | "UnresolvedPure" | "UnresolvedObject">[];
|
|
194
194
|
commands: _mysten_bcs1241.EnumOutputShapeWithKeys<{
|
|
195
195
|
MoveCall: {
|
|
196
196
|
package: string;
|
package/dist/version.mjs
CHANGED
package/dist/version.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.
|
|
1
|
+
{"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.32.0';\n"],"mappings":";AAKA,MAAa,kBAAkB"}
|
package/docs/clients/grpc.md
CHANGED
|
@@ -69,7 +69,13 @@ That class extends the transport of the same name from
|
|
|
69
69
|
`AbortSignal.timeout`, the status on a reason carrying one, and `CANCELLED` otherwise. Upstream
|
|
70
70
|
reports all but a standard `AbortError` cancellation as `INTERNAL`.
|
|
71
71
|
|
|
72
|
-
Build custom transports from this class
|
|
72
|
+
Build custom gRPC-web transports from this class to retain these error-handling fixes.
|
|
73
|
+
|
|
74
|
+
`SuiGrpcClient` adds an `x-sui-client-protocol-version` request header with the highest Sui protocol
|
|
75
|
+
version whose types the SDK can decode. This applies to all transports, including native gRPC, and
|
|
76
|
+
to unary and streaming requests. Explicit values in the transport's `meta` options or an individual
|
|
77
|
+
service call's `meta` override the default. The client does not mutate a supplied transport or
|
|
78
|
+
change its error handling.
|
|
73
79
|
|
|
74
80
|
### gRPC-web transport (default)
|
|
75
81
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/** Request header carrying the highest protocol version whose types the client can decode. */
|
|
5
|
+
export const CLIENT_PROTOCOL_VERSION_HEADER = 'x-sui-client-protocol-version';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Highest Sui protocol version whose on-chain types this SDK can decode. Bump this when the SDK
|
|
9
|
+
* gains support for types introduced in a newer protocol version.
|
|
10
|
+
*/
|
|
11
|
+
export const MAX_PROTOCOL_VERSION = 138;
|
package/src/graphql/client.ts
CHANGED
|
@@ -5,6 +5,10 @@ import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
|
5
5
|
import type { TadaDocumentNode } from 'gql.tada';
|
|
6
6
|
import type { DocumentNode } from 'graphql';
|
|
7
7
|
import { print } from 'graphql';
|
|
8
|
+
import {
|
|
9
|
+
CLIENT_PROTOCOL_VERSION_HEADER,
|
|
10
|
+
MAX_PROTOCOL_VERSION,
|
|
11
|
+
} from '../client/protocol-version.js';
|
|
8
12
|
import { BaseClient } from '../client/index.js';
|
|
9
13
|
import type { SuiClientTypes } from '../client/index.js';
|
|
10
14
|
import { GraphQLCoreClient } from './core.js';
|
|
@@ -137,12 +141,17 @@ export class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> =
|
|
|
137
141
|
async query<Result = Record<string, unknown>, Variables = Record<string, unknown>>(
|
|
138
142
|
options: GraphQLQueryOptions<Result, Variables>,
|
|
139
143
|
): Promise<GraphQLQueryResult<Result>> {
|
|
144
|
+
const headers = new Headers({
|
|
145
|
+
'Content-Type': 'application/json',
|
|
146
|
+
...this.#headers,
|
|
147
|
+
});
|
|
148
|
+
if (!headers.has(CLIENT_PROTOCOL_VERSION_HEADER)) {
|
|
149
|
+
headers.set(CLIENT_PROTOCOL_VERSION_HEADER, String(MAX_PROTOCOL_VERSION));
|
|
150
|
+
}
|
|
151
|
+
|
|
140
152
|
const res = await this.#fetch(this.#url, {
|
|
141
153
|
method: 'POST',
|
|
142
|
-
headers
|
|
143
|
-
'Content-Type': 'application/json',
|
|
144
|
-
...this.#headers,
|
|
145
|
-
},
|
|
154
|
+
headers,
|
|
146
155
|
body: JSON.stringify({
|
|
147
156
|
query:
|
|
148
157
|
typeof options.query === 'string' || options.query instanceof String
|
package/src/grpc/client.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { fromBase64, toBase64 } from '@mysten/utils';
|
|
|
18
18
|
import { NameServiceClient } from './proto/sui/rpc/v2/name_service.client.js';
|
|
19
19
|
import { ForkingServiceClient } from './proto/sui/forking/v1alpha/forking_service.client.js';
|
|
20
20
|
import type { TransactionPlugin } from '../transactions/index.js';
|
|
21
|
-
import { GrpcWebFetchTransport } from './transport.js';
|
|
21
|
+
import { GrpcWebFetchTransport, withClientProtocolVersion } from './transport.js';
|
|
22
22
|
|
|
23
23
|
interface SuiGrpcTransportOptions extends GrpcWebOptions {
|
|
24
24
|
transport?: never;
|
|
@@ -166,8 +166,10 @@ export class SuiGrpcClient extends BaseClient implements SuiClientTypes.Transpor
|
|
|
166
166
|
...transportOptions
|
|
167
167
|
} = options as SuiGrpcClientOptions & SuiGrpcTransportOptions & { transport?: RpcTransport };
|
|
168
168
|
|
|
169
|
-
//
|
|
170
|
-
const transport =
|
|
169
|
+
// Add the protocol-version default for every transport, including native gRPC.
|
|
170
|
+
const transport = withClientProtocolVersion(
|
|
171
|
+
providedTransport ?? new GrpcWebFetchTransport(transportOptions),
|
|
172
|
+
);
|
|
171
173
|
this.transactionExecutionService = new TransactionExecutionServiceClient(transport);
|
|
172
174
|
this.ledgerService = new LedgerServiceClient(transport);
|
|
173
175
|
this.stateService = new StateServiceClient(transport);
|
package/src/grpc/transport.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { GrpcWebOptions } from '@protobuf-ts/grpcweb-transport';
|
|
4
5
|
import { GrpcStatusCode } from '@protobuf-ts/grpcweb-transport';
|
|
5
6
|
import { GrpcWebFetchTransport as UpstreamGrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport';
|
|
6
7
|
import type {
|
|
7
8
|
MethodInfo,
|
|
8
9
|
RpcOptions,
|
|
10
|
+
RpcTransport,
|
|
9
11
|
ServerStreamingCall,
|
|
10
12
|
UnaryCall,
|
|
11
13
|
} from '@protobuf-ts/runtime-rpc';
|
|
12
14
|
import { RpcError } from '@protobuf-ts/runtime-rpc';
|
|
13
15
|
|
|
16
|
+
import {
|
|
17
|
+
CLIENT_PROTOCOL_VERSION_HEADER,
|
|
18
|
+
MAX_PROTOCOL_VERSION,
|
|
19
|
+
} from '../client/protocol-version.js';
|
|
20
|
+
|
|
14
21
|
// A failed call rejects four promises with the same error, so it is only decoded once. Registered
|
|
15
22
|
// globally so another installed copy of this package sees the same marker.
|
|
16
23
|
const MESSAGE_DECODED = Symbol.for('@mysten/sui/grpc/decoded-status-message');
|
|
@@ -126,12 +133,24 @@ function normalizeRejections(promises: Promise<unknown>[], signal: AbortSignal |
|
|
|
126
133
|
|
|
127
134
|
/**
|
|
128
135
|
* `GrpcWebFetchTransport` from `@protobuf-ts/grpcweb-transport`, subclassed to decode status
|
|
129
|
-
* messages
|
|
136
|
+
* messages, to code an aborted call from its reason rather than as `INTERNAL`, and to send the
|
|
137
|
+
* `x-sui-client-protocol-version` header.
|
|
130
138
|
*
|
|
131
139
|
* `SuiGrpcClient` builds one by default. A transport imported from `@protobuf-ts/grpcweb-transport`
|
|
132
140
|
* keeps that package's behaviour.
|
|
133
141
|
*/
|
|
134
142
|
export class GrpcWebFetchTransport extends UpstreamGrpcWebFetchTransport {
|
|
143
|
+
constructor(options: GrpcWebOptions) {
|
|
144
|
+
// Lets the server avoid sending types this SDK cannot decode. Caller-supplied `meta` wins.
|
|
145
|
+
super({
|
|
146
|
+
...options,
|
|
147
|
+
meta: {
|
|
148
|
+
[CLIENT_PROTOCOL_VERSION_HEADER]: String(MAX_PROTOCOL_VERSION),
|
|
149
|
+
...options.meta,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
135
154
|
override unary<I extends object, O extends object>(
|
|
136
155
|
method: MethodInfo<I, O>,
|
|
137
156
|
input: I,
|
|
@@ -158,3 +177,23 @@ export class GrpcWebFetchTransport extends UpstreamGrpcWebFetchTransport {
|
|
|
158
177
|
return call;
|
|
159
178
|
}
|
|
160
179
|
}
|
|
180
|
+
|
|
181
|
+
/** Adds SDK metadata without mutating the caller's transport or its default options. */
|
|
182
|
+
export function withClientProtocolVersion(transport: RpcTransport): RpcTransport {
|
|
183
|
+
return {
|
|
184
|
+
mergeOptions(options) {
|
|
185
|
+
const merged = transport.mergeOptions(options);
|
|
186
|
+
return {
|
|
187
|
+
...merged,
|
|
188
|
+
meta: {
|
|
189
|
+
[CLIENT_PROTOCOL_VERSION_HEADER]: String(MAX_PROTOCOL_VERSION),
|
|
190
|
+
...merged.meta,
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
unary: transport.unary.bind(transport),
|
|
195
|
+
serverStreaming: transport.serverStreaming.bind(transport),
|
|
196
|
+
clientStreaming: transport.clientStreaming.bind(transport),
|
|
197
|
+
duplex: transport.duplex.bind(transport),
|
|
198
|
+
};
|
|
199
|
+
}
|
package/src/version.ts
CHANGED