@0xsequence/api 1.9.24 → 1.9.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/0xsequence-api.cjs.dev.js +494 -97
- package/dist/0xsequence-api.cjs.prod.js +494 -97
- package/dist/0xsequence-api.esm.js +474 -98
- package/dist/declarations/src/api.gen.d.ts +202 -89
- package/package.json +1 -1
- package/src/api.gen.ts +1079 -410
package/src/api.gen.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
// sequence-api v0.4.0
|
|
2
|
+
// sequence-api v0.4.0 3c1782dee5a602d773450bdb42c84515771d30d1
|
|
3
3
|
// --
|
|
4
|
-
// Code generated by webrpc-gen@v0.18.
|
|
4
|
+
// Code generated by webrpc-gen@v0.18.6 with typescript generator. DO NOT EDIT.
|
|
5
5
|
//
|
|
6
|
-
// webrpc-gen -schema=api.ridl -target=typescript
|
|
6
|
+
// webrpc-gen -schema=api.ridl -target=typescript -client -out=./clients/api.gen.ts
|
|
7
7
|
|
|
8
8
|
// WebRPC description and code-gen version
|
|
9
9
|
export const WebRPCVersion = 'v1'
|
|
@@ -12,7 +12,7 @@ export const WebRPCVersion = 'v1'
|
|
|
12
12
|
export const WebRPCSchemaVersion = 'v0.4.0'
|
|
13
13
|
|
|
14
14
|
// Schema hash generated from your RIDL schema
|
|
15
|
-
export const WebRPCSchemaHash = '
|
|
15
|
+
export const WebRPCSchemaHash = '3c1782dee5a602d773450bdb42c84515771d30d1'
|
|
16
16
|
|
|
17
17
|
//
|
|
18
18
|
// Types
|
|
@@ -61,7 +61,6 @@ export interface SequenceContext {
|
|
|
61
61
|
export interface User {
|
|
62
62
|
address: string
|
|
63
63
|
username: string
|
|
64
|
-
|
|
65
64
|
avatar: string
|
|
66
65
|
bio: string
|
|
67
66
|
location: string
|
|
@@ -208,49 +207,108 @@ export interface NftCheckout {
|
|
|
208
207
|
orderId: string
|
|
209
208
|
}
|
|
210
209
|
|
|
210
|
+
export interface SardineOrder {
|
|
211
|
+
id: string
|
|
212
|
+
createdAt?: string
|
|
213
|
+
referenceId: string
|
|
214
|
+
status: string
|
|
215
|
+
fiatCurrency: string
|
|
216
|
+
fiatExchangeRateUSD: number
|
|
217
|
+
transactionId: string
|
|
218
|
+
expiresAt?: string
|
|
219
|
+
total: number
|
|
220
|
+
subTotal: number
|
|
221
|
+
transactionFee: number
|
|
222
|
+
networkFee: number
|
|
223
|
+
paymentCurrency?: string
|
|
224
|
+
paymentMethodType?: string
|
|
225
|
+
transactionType: string
|
|
226
|
+
name: string
|
|
227
|
+
price: number
|
|
228
|
+
imageUrl: string
|
|
229
|
+
contractAddress?: string
|
|
230
|
+
}
|
|
231
|
+
|
|
211
232
|
export interface API {
|
|
212
|
-
ping(headers?: object): Promise<PingReturn>
|
|
213
|
-
version(headers?: object): Promise<VersionReturn>
|
|
214
|
-
runtimeStatus(headers?: object): Promise<RuntimeStatusReturn>
|
|
215
|
-
clock(headers?: object): Promise<ClockReturn>
|
|
216
|
-
getSequenceContext(headers?: object): Promise<GetSequenceContextReturn>
|
|
217
|
-
getAuthToken(args: GetAuthTokenArgs, headers?: object): Promise<GetAuthTokenReturn>
|
|
218
|
-
getAuthToken2(args: GetAuthToken2Args, headers?: object): Promise<GetAuthToken2Return>
|
|
219
|
-
sendPasswordlessLink(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
233
|
+
ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>
|
|
234
|
+
version(headers?: object, signal?: AbortSignal): Promise<VersionReturn>
|
|
235
|
+
runtimeStatus(headers?: object, signal?: AbortSignal): Promise<RuntimeStatusReturn>
|
|
236
|
+
clock(headers?: object, signal?: AbortSignal): Promise<ClockReturn>
|
|
237
|
+
getSequenceContext(headers?: object, signal?: AbortSignal): Promise<GetSequenceContextReturn>
|
|
238
|
+
getAuthToken(args: GetAuthTokenArgs, headers?: object, signal?: AbortSignal): Promise<GetAuthTokenReturn>
|
|
239
|
+
getAuthToken2(args: GetAuthToken2Args, headers?: object, signal?: AbortSignal): Promise<GetAuthToken2Return>
|
|
240
|
+
sendPasswordlessLink(
|
|
241
|
+
args: SendPasswordlessLinkArgs,
|
|
242
|
+
headers?: object,
|
|
243
|
+
signal?: AbortSignal
|
|
244
|
+
): Promise<SendPasswordlessLinkReturn>
|
|
245
|
+
friendList(args: FriendListArgs, headers?: object, signal?: AbortSignal): Promise<FriendListReturn>
|
|
246
|
+
getFriendByAddress(args: GetFriendByAddressArgs, headers?: object, signal?: AbortSignal): Promise<GetFriendByAddressReturn>
|
|
247
|
+
searchFriends(args: SearchFriendsArgs, headers?: object, signal?: AbortSignal): Promise<SearchFriendsReturn>
|
|
248
|
+
addFriend(args: AddFriendArgs, headers?: object, signal?: AbortSignal): Promise<AddFriendReturn>
|
|
249
|
+
updateFriendNickname(
|
|
250
|
+
args: UpdateFriendNicknameArgs,
|
|
251
|
+
headers?: object,
|
|
252
|
+
signal?: AbortSignal
|
|
253
|
+
): Promise<UpdateFriendNicknameReturn>
|
|
254
|
+
removeFriend(args: RemoveFriendArgs, headers?: object, signal?: AbortSignal): Promise<RemoveFriendReturn>
|
|
255
|
+
contractCall(args: ContractCallArgs, headers?: object, signal?: AbortSignal): Promise<ContractCallReturn>
|
|
256
|
+
decodeContractCall(args: DecodeContractCallArgs, headers?: object, signal?: AbortSignal): Promise<DecodeContractCallReturn>
|
|
257
|
+
lookupContractCallSelectors(
|
|
258
|
+
args: LookupContractCallSelectorsArgs,
|
|
259
|
+
headers?: object,
|
|
260
|
+
signal?: AbortSignal
|
|
261
|
+
): Promise<LookupContractCallSelectorsReturn>
|
|
262
|
+
userStorageFetch(args: UserStorageFetchArgs, headers?: object, signal?: AbortSignal): Promise<UserStorageFetchReturn>
|
|
263
|
+
userStorageSave(args: UserStorageSaveArgs, headers?: object, signal?: AbortSignal): Promise<UserStorageSaveReturn>
|
|
264
|
+
userStorageDelete(args: UserStorageDeleteArgs, headers?: object, signal?: AbortSignal): Promise<UserStorageDeleteReturn>
|
|
265
|
+
userStorageFetchAll(args: UserStorageFetchAllArgs, headers?: object, signal?: AbortSignal): Promise<UserStorageFetchAllReturn>
|
|
266
|
+
getMoonpayLink(args: GetMoonpayLinkArgs, headers?: object, signal?: AbortSignal): Promise<GetMoonpayLinkReturn>
|
|
267
|
+
getSardineClientToken(headers?: object, signal?: AbortSignal): Promise<GetSardineClientTokenReturn>
|
|
268
|
+
getSardineNFTCheckoutToken(
|
|
269
|
+
args: GetSardineNFTCheckoutTokenArgs,
|
|
270
|
+
headers?: object,
|
|
271
|
+
signal?: AbortSignal
|
|
272
|
+
): Promise<GetSardineNFTCheckoutTokenReturn>
|
|
273
|
+
getSardineNFTCheckoutOrderStatus(
|
|
274
|
+
args: GetSardineNFTCheckoutOrderStatusArgs,
|
|
275
|
+
headers?: object,
|
|
276
|
+
signal?: AbortSignal
|
|
277
|
+
): Promise<GetSardineNFTCheckoutOrderStatusReturn>
|
|
278
|
+
resolveENSAddress(args: ResolveENSAddressArgs, headers?: object, signal?: AbortSignal): Promise<ResolveENSAddressReturn>
|
|
279
|
+
isValidSignature(args: IsValidSignatureArgs, headers?: object, signal?: AbortSignal): Promise<IsValidSignatureReturn>
|
|
280
|
+
isValidMessageSignature(
|
|
281
|
+
args: IsValidMessageSignatureArgs,
|
|
282
|
+
headers?: object,
|
|
283
|
+
signal?: AbortSignal
|
|
284
|
+
): Promise<IsValidMessageSignatureReturn>
|
|
285
|
+
isValidTypedDataSignature(
|
|
286
|
+
args: IsValidTypedDataSignatureArgs,
|
|
287
|
+
headers?: object,
|
|
288
|
+
signal?: AbortSignal
|
|
289
|
+
): Promise<IsValidTypedDataSignatureReturn>
|
|
290
|
+
isValidETHAuthProof(args: IsValidETHAuthProofArgs, headers?: object, signal?: AbortSignal): Promise<IsValidETHAuthProofReturn>
|
|
291
|
+
getCoinPrices(args: GetCoinPricesArgs, headers?: object, signal?: AbortSignal): Promise<GetCoinPricesReturn>
|
|
292
|
+
getCollectiblePrices(
|
|
293
|
+
args: GetCollectiblePricesArgs,
|
|
294
|
+
headers?: object,
|
|
295
|
+
signal?: AbortSignal
|
|
296
|
+
): Promise<GetCollectiblePricesReturn>
|
|
297
|
+
getExchangeRate(args: GetExchangeRateArgs, headers?: object, signal?: AbortSignal): Promise<GetExchangeRateReturn>
|
|
298
|
+
memoryStore(args: MemoryStoreArgs, headers?: object, signal?: AbortSignal): Promise<MemoryStoreReturn>
|
|
299
|
+
memoryLoad(args: MemoryLoadArgs, headers?: object, signal?: AbortSignal): Promise<MemoryLoadReturn>
|
|
300
|
+
getInviteInfo(headers?: object, signal?: AbortSignal): Promise<GetInviteInfoReturn>
|
|
301
|
+
isValidAccessCode(args: IsValidAccessCodeArgs, headers?: object, signal?: AbortSignal): Promise<IsValidAccessCodeReturn>
|
|
302
|
+
internalClaimAccessCode(
|
|
303
|
+
args: InternalClaimAccessCodeArgs,
|
|
304
|
+
headers?: object,
|
|
305
|
+
signal?: AbortSignal
|
|
306
|
+
): Promise<InternalClaimAccessCodeReturn>
|
|
307
|
+
blockNumberAtTime(args: BlockNumberAtTimeArgs, headers?: object, signal?: AbortSignal): Promise<BlockNumberAtTimeReturn>
|
|
308
|
+
paperSessionSecret(args: PaperSessionSecretArgs, headers?: object, signal?: AbortSignal): Promise<PaperSessionSecretReturn>
|
|
309
|
+
paperSessionSecret2(args: PaperSessionSecret2Args, headers?: object, signal?: AbortSignal): Promise<PaperSessionSecret2Return>
|
|
310
|
+
linkWallet(args: LinkWalletArgs, headers?: object, signal?: AbortSignal): Promise<LinkWalletReturn>
|
|
311
|
+
getLinkedWallets(args: GetLinkedWalletsArgs, headers?: object, signal?: AbortSignal): Promise<GetLinkedWalletsReturn>
|
|
254
312
|
}
|
|
255
313
|
|
|
256
314
|
export interface PingArgs {}
|
|
@@ -432,6 +490,13 @@ export interface GetSardineNFTCheckoutTokenArgs {
|
|
|
432
490
|
export interface GetSardineNFTCheckoutTokenReturn {
|
|
433
491
|
resp: NftCheckout
|
|
434
492
|
}
|
|
493
|
+
export interface GetSardineNFTCheckoutOrderStatusArgs {
|
|
494
|
+
orderId: string
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export interface GetSardineNFTCheckoutOrderStatusReturn {
|
|
498
|
+
resp: SardineOrder
|
|
499
|
+
}
|
|
435
500
|
export interface ResolveENSAddressArgs {
|
|
436
501
|
ens: string
|
|
437
502
|
}
|
|
@@ -600,459 +665,730 @@ export class API implements API {
|
|
|
600
665
|
return this.hostname + this.path + name
|
|
601
666
|
}
|
|
602
667
|
|
|
603
|
-
ping = (headers?: object): Promise<PingReturn> => {
|
|
604
|
-
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(
|
|
605
|
-
|
|
606
|
-
return {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
668
|
+
ping = (headers?: object, signal?: AbortSignal): Promise<PingReturn> => {
|
|
669
|
+
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(
|
|
670
|
+
res => {
|
|
671
|
+
return buildResponse(res).then(_data => {
|
|
672
|
+
return {
|
|
673
|
+
status: <boolean>_data.status
|
|
674
|
+
}
|
|
675
|
+
})
|
|
676
|
+
},
|
|
677
|
+
error => {
|
|
678
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
679
|
+
}
|
|
680
|
+
)
|
|
611
681
|
}
|
|
612
682
|
|
|
613
|
-
version = (headers?: object): Promise<VersionReturn> => {
|
|
614
|
-
return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(
|
|
615
|
-
|
|
616
|
-
return {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
683
|
+
version = (headers?: object, signal?: AbortSignal): Promise<VersionReturn> => {
|
|
684
|
+
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(
|
|
685
|
+
res => {
|
|
686
|
+
return buildResponse(res).then(_data => {
|
|
687
|
+
return {
|
|
688
|
+
version: <Version>_data.version
|
|
689
|
+
}
|
|
690
|
+
})
|
|
691
|
+
},
|
|
692
|
+
error => {
|
|
693
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
694
|
+
}
|
|
695
|
+
)
|
|
621
696
|
}
|
|
622
697
|
|
|
623
|
-
runtimeStatus = (headers?: object): Promise<RuntimeStatusReturn> => {
|
|
624
|
-
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(
|
|
625
|
-
|
|
626
|
-
return {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
698
|
+
runtimeStatus = (headers?: object, signal?: AbortSignal): Promise<RuntimeStatusReturn> => {
|
|
699
|
+
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(
|
|
700
|
+
res => {
|
|
701
|
+
return buildResponse(res).then(_data => {
|
|
702
|
+
return {
|
|
703
|
+
status: <RuntimeStatus>_data.status
|
|
704
|
+
}
|
|
705
|
+
})
|
|
706
|
+
},
|
|
707
|
+
error => {
|
|
708
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
709
|
+
}
|
|
710
|
+
)
|
|
631
711
|
}
|
|
632
712
|
|
|
633
|
-
clock = (headers?: object): Promise<ClockReturn> => {
|
|
634
|
-
return this.fetch(this.url('Clock'), createHTTPRequest({}, headers)).then(
|
|
635
|
-
|
|
636
|
-
return {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
713
|
+
clock = (headers?: object, signal?: AbortSignal): Promise<ClockReturn> => {
|
|
714
|
+
return this.fetch(this.url('Clock'), createHTTPRequest({}, headers, signal)).then(
|
|
715
|
+
res => {
|
|
716
|
+
return buildResponse(res).then(_data => {
|
|
717
|
+
return {
|
|
718
|
+
serverTime: <string>_data.serverTime
|
|
719
|
+
}
|
|
720
|
+
})
|
|
721
|
+
},
|
|
722
|
+
error => {
|
|
723
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
724
|
+
}
|
|
725
|
+
)
|
|
641
726
|
}
|
|
642
727
|
|
|
643
|
-
getSequenceContext = (headers?: object): Promise<GetSequenceContextReturn> => {
|
|
644
|
-
return this.fetch(this.url('GetSequenceContext'), createHTTPRequest({}, headers)).then(
|
|
645
|
-
|
|
646
|
-
return {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
return {
|
|
657
|
-
status: <boolean>_data.status,
|
|
658
|
-
jwtToken: <string>_data.jwtToken,
|
|
659
|
-
address: <string>_data.address,
|
|
660
|
-
user: <User>_data.user
|
|
661
|
-
}
|
|
662
|
-
})
|
|
663
|
-
})
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
getAuthToken2 = (args: GetAuthToken2Args, headers?: object): Promise<GetAuthToken2Return> => {
|
|
667
|
-
return this.fetch(this.url('GetAuthToken2'), createHTTPRequest(args, headers)).then(res => {
|
|
668
|
-
return buildResponse(res).then(_data => {
|
|
669
|
-
return {
|
|
670
|
-
status: <boolean>_data.status,
|
|
671
|
-
jwtToken: <string>_data.jwtToken,
|
|
672
|
-
address: <string>_data.address,
|
|
673
|
-
user: <User>_data.user
|
|
674
|
-
}
|
|
675
|
-
})
|
|
676
|
-
})
|
|
728
|
+
getSequenceContext = (headers?: object, signal?: AbortSignal): Promise<GetSequenceContextReturn> => {
|
|
729
|
+
return this.fetch(this.url('GetSequenceContext'), createHTTPRequest({}, headers, signal)).then(
|
|
730
|
+
res => {
|
|
731
|
+
return buildResponse(res).then(_data => {
|
|
732
|
+
return {
|
|
733
|
+
data: <SequenceContext>_data.data
|
|
734
|
+
}
|
|
735
|
+
})
|
|
736
|
+
},
|
|
737
|
+
error => {
|
|
738
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
739
|
+
}
|
|
740
|
+
)
|
|
677
741
|
}
|
|
678
742
|
|
|
679
|
-
|
|
680
|
-
return this.fetch(this.url('
|
|
681
|
-
|
|
682
|
-
return {
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
743
|
+
getAuthToken = (args: GetAuthTokenArgs, headers?: object, signal?: AbortSignal): Promise<GetAuthTokenReturn> => {
|
|
744
|
+
return this.fetch(this.url('GetAuthToken'), createHTTPRequest(args, headers, signal)).then(
|
|
745
|
+
res => {
|
|
746
|
+
return buildResponse(res).then(_data => {
|
|
747
|
+
return {
|
|
748
|
+
status: <boolean>_data.status,
|
|
749
|
+
jwtToken: <string>_data.jwtToken,
|
|
750
|
+
address: <string>_data.address,
|
|
751
|
+
user: <User>_data.user
|
|
752
|
+
}
|
|
753
|
+
})
|
|
754
|
+
},
|
|
755
|
+
error => {
|
|
756
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
757
|
+
}
|
|
758
|
+
)
|
|
687
759
|
}
|
|
688
760
|
|
|
689
|
-
|
|
690
|
-
return this.fetch(this.url('
|
|
691
|
-
|
|
692
|
-
return {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
761
|
+
getAuthToken2 = (args: GetAuthToken2Args, headers?: object, signal?: AbortSignal): Promise<GetAuthToken2Return> => {
|
|
762
|
+
return this.fetch(this.url('GetAuthToken2'), createHTTPRequest(args, headers, signal)).then(
|
|
763
|
+
res => {
|
|
764
|
+
return buildResponse(res).then(_data => {
|
|
765
|
+
return {
|
|
766
|
+
status: <boolean>_data.status,
|
|
767
|
+
jwtToken: <string>_data.jwtToken,
|
|
768
|
+
address: <string>_data.address,
|
|
769
|
+
user: <User>_data.user
|
|
770
|
+
}
|
|
771
|
+
})
|
|
772
|
+
},
|
|
773
|
+
error => {
|
|
774
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
775
|
+
}
|
|
776
|
+
)
|
|
698
777
|
}
|
|
699
778
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
779
|
+
sendPasswordlessLink = (
|
|
780
|
+
args: SendPasswordlessLinkArgs,
|
|
781
|
+
headers?: object,
|
|
782
|
+
signal?: AbortSignal
|
|
783
|
+
): Promise<SendPasswordlessLinkReturn> => {
|
|
784
|
+
return this.fetch(this.url('SendPasswordlessLink'), createHTTPRequest(args, headers, signal)).then(
|
|
785
|
+
res => {
|
|
786
|
+
return buildResponse(res).then(_data => {
|
|
787
|
+
return {
|
|
788
|
+
status: <boolean>_data.status
|
|
789
|
+
}
|
|
790
|
+
})
|
|
791
|
+
},
|
|
792
|
+
error => {
|
|
793
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
794
|
+
}
|
|
795
|
+
)
|
|
709
796
|
}
|
|
710
797
|
|
|
711
|
-
|
|
712
|
-
return this.fetch(this.url('
|
|
713
|
-
|
|
714
|
-
return {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
798
|
+
friendList = (args: FriendListArgs, headers?: object, signal?: AbortSignal): Promise<FriendListReturn> => {
|
|
799
|
+
return this.fetch(this.url('FriendList'), createHTTPRequest(args, headers, signal)).then(
|
|
800
|
+
res => {
|
|
801
|
+
return buildResponse(res).then(_data => {
|
|
802
|
+
return {
|
|
803
|
+
page: <Page>_data.page,
|
|
804
|
+
friends: <Array<Friend>>_data.friends
|
|
805
|
+
}
|
|
806
|
+
})
|
|
807
|
+
},
|
|
808
|
+
error => {
|
|
809
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
810
|
+
}
|
|
811
|
+
)
|
|
719
812
|
}
|
|
720
813
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
814
|
+
getFriendByAddress = (
|
|
815
|
+
args: GetFriendByAddressArgs,
|
|
816
|
+
headers?: object,
|
|
817
|
+
signal?: AbortSignal
|
|
818
|
+
): Promise<GetFriendByAddressReturn> => {
|
|
819
|
+
return this.fetch(this.url('GetFriendByAddress'), createHTTPRequest(args, headers, signal)).then(
|
|
820
|
+
res => {
|
|
821
|
+
return buildResponse(res).then(_data => {
|
|
822
|
+
return {
|
|
823
|
+
status: <boolean>_data.status,
|
|
824
|
+
friend: <Friend>_data.friend
|
|
825
|
+
}
|
|
826
|
+
})
|
|
827
|
+
},
|
|
828
|
+
error => {
|
|
829
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
830
|
+
}
|
|
831
|
+
)
|
|
730
832
|
}
|
|
731
833
|
|
|
732
|
-
|
|
733
|
-
return this.fetch(this.url('
|
|
734
|
-
|
|
735
|
-
return {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
834
|
+
searchFriends = (args: SearchFriendsArgs, headers?: object, signal?: AbortSignal): Promise<SearchFriendsReturn> => {
|
|
835
|
+
return this.fetch(this.url('SearchFriends'), createHTTPRequest(args, headers, signal)).then(
|
|
836
|
+
res => {
|
|
837
|
+
return buildResponse(res).then(_data => {
|
|
838
|
+
return {
|
|
839
|
+
friends: <Array<Friend>>_data.friends
|
|
840
|
+
}
|
|
841
|
+
})
|
|
842
|
+
},
|
|
843
|
+
error => {
|
|
844
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
845
|
+
}
|
|
846
|
+
)
|
|
741
847
|
}
|
|
742
848
|
|
|
743
|
-
|
|
744
|
-
return this.fetch(this.url('
|
|
745
|
-
|
|
746
|
-
return {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
849
|
+
addFriend = (args: AddFriendArgs, headers?: object, signal?: AbortSignal): Promise<AddFriendReturn> => {
|
|
850
|
+
return this.fetch(this.url('AddFriend'), createHTTPRequest(args, headers, signal)).then(
|
|
851
|
+
res => {
|
|
852
|
+
return buildResponse(res).then(_data => {
|
|
853
|
+
return {
|
|
854
|
+
status: <boolean>_data.status,
|
|
855
|
+
friend: <Friend>_data.friend
|
|
856
|
+
}
|
|
857
|
+
})
|
|
858
|
+
},
|
|
859
|
+
error => {
|
|
860
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
861
|
+
}
|
|
862
|
+
)
|
|
751
863
|
}
|
|
752
864
|
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
865
|
+
updateFriendNickname = (
|
|
866
|
+
args: UpdateFriendNicknameArgs,
|
|
867
|
+
headers?: object,
|
|
868
|
+
signal?: AbortSignal
|
|
869
|
+
): Promise<UpdateFriendNicknameReturn> => {
|
|
870
|
+
return this.fetch(this.url('UpdateFriendNickname'), createHTTPRequest(args, headers, signal)).then(
|
|
871
|
+
res => {
|
|
872
|
+
return buildResponse(res).then(_data => {
|
|
873
|
+
return {
|
|
874
|
+
status: <boolean>_data.status,
|
|
875
|
+
friend: <Friend>_data.friend
|
|
876
|
+
}
|
|
877
|
+
})
|
|
878
|
+
},
|
|
879
|
+
error => {
|
|
880
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
881
|
+
}
|
|
882
|
+
)
|
|
761
883
|
}
|
|
762
884
|
|
|
763
|
-
|
|
764
|
-
return this.fetch(this.url('
|
|
765
|
-
|
|
766
|
-
return {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
885
|
+
removeFriend = (args: RemoveFriendArgs, headers?: object, signal?: AbortSignal): Promise<RemoveFriendReturn> => {
|
|
886
|
+
return this.fetch(this.url('RemoveFriend'), createHTTPRequest(args, headers, signal)).then(
|
|
887
|
+
res => {
|
|
888
|
+
return buildResponse(res).then(_data => {
|
|
889
|
+
return {
|
|
890
|
+
status: <boolean>_data.status
|
|
891
|
+
}
|
|
892
|
+
})
|
|
893
|
+
},
|
|
894
|
+
error => {
|
|
895
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
896
|
+
}
|
|
897
|
+
)
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
contractCall = (args: ContractCallArgs, headers?: object, signal?: AbortSignal): Promise<ContractCallReturn> => {
|
|
901
|
+
return this.fetch(this.url('ContractCall'), createHTTPRequest(args, headers, signal)).then(
|
|
902
|
+
res => {
|
|
903
|
+
return buildResponse(res).then(_data => {
|
|
904
|
+
return {
|
|
905
|
+
returns: <Array<string>>_data.returns
|
|
906
|
+
}
|
|
907
|
+
})
|
|
908
|
+
},
|
|
909
|
+
error => {
|
|
910
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
911
|
+
}
|
|
912
|
+
)
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
decodeContractCall = (
|
|
916
|
+
args: DecodeContractCallArgs,
|
|
917
|
+
headers?: object,
|
|
918
|
+
signal?: AbortSignal
|
|
919
|
+
): Promise<DecodeContractCallReturn> => {
|
|
920
|
+
return this.fetch(this.url('DecodeContractCall'), createHTTPRequest(args, headers, signal)).then(
|
|
921
|
+
res => {
|
|
922
|
+
return buildResponse(res).then(_data => {
|
|
923
|
+
return {
|
|
924
|
+
call: <ContractCall>_data.call
|
|
925
|
+
}
|
|
926
|
+
})
|
|
927
|
+
},
|
|
928
|
+
error => {
|
|
929
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
930
|
+
}
|
|
931
|
+
)
|
|
771
932
|
}
|
|
772
933
|
|
|
773
934
|
lookupContractCallSelectors = (
|
|
774
935
|
args: LookupContractCallSelectorsArgs,
|
|
775
|
-
headers?: object
|
|
936
|
+
headers?: object,
|
|
937
|
+
signal?: AbortSignal
|
|
776
938
|
): Promise<LookupContractCallSelectorsReturn> => {
|
|
777
|
-
return this.fetch(this.url('LookupContractCallSelectors'), createHTTPRequest(args, headers)).then(
|
|
778
|
-
|
|
779
|
-
return {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
939
|
+
return this.fetch(this.url('LookupContractCallSelectors'), createHTTPRequest(args, headers, signal)).then(
|
|
940
|
+
res => {
|
|
941
|
+
return buildResponse(res).then(_data => {
|
|
942
|
+
return {
|
|
943
|
+
signatures: <Array<Array<string>>>_data.signatures
|
|
944
|
+
}
|
|
945
|
+
})
|
|
946
|
+
},
|
|
947
|
+
error => {
|
|
948
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
949
|
+
}
|
|
950
|
+
)
|
|
784
951
|
}
|
|
785
952
|
|
|
786
|
-
userStorageFetch = (args: UserStorageFetchArgs, headers?: object): Promise<UserStorageFetchReturn> => {
|
|
787
|
-
return this.fetch(this.url('UserStorageFetch'), createHTTPRequest(args, headers)).then(
|
|
788
|
-
|
|
789
|
-
return {
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
953
|
+
userStorageFetch = (args: UserStorageFetchArgs, headers?: object, signal?: AbortSignal): Promise<UserStorageFetchReturn> => {
|
|
954
|
+
return this.fetch(this.url('UserStorageFetch'), createHTTPRequest(args, headers, signal)).then(
|
|
955
|
+
res => {
|
|
956
|
+
return buildResponse(res).then(_data => {
|
|
957
|
+
return {
|
|
958
|
+
object: <any>_data.object
|
|
959
|
+
}
|
|
960
|
+
})
|
|
961
|
+
},
|
|
962
|
+
error => {
|
|
963
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
964
|
+
}
|
|
965
|
+
)
|
|
794
966
|
}
|
|
795
967
|
|
|
796
|
-
userStorageSave = (args: UserStorageSaveArgs, headers?: object): Promise<UserStorageSaveReturn> => {
|
|
797
|
-
return this.fetch(this.url('UserStorageSave'), createHTTPRequest(args, headers)).then(
|
|
798
|
-
|
|
799
|
-
return {
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
968
|
+
userStorageSave = (args: UserStorageSaveArgs, headers?: object, signal?: AbortSignal): Promise<UserStorageSaveReturn> => {
|
|
969
|
+
return this.fetch(this.url('UserStorageSave'), createHTTPRequest(args, headers, signal)).then(
|
|
970
|
+
res => {
|
|
971
|
+
return buildResponse(res).then(_data => {
|
|
972
|
+
return {
|
|
973
|
+
ok: <boolean>_data.ok
|
|
974
|
+
}
|
|
975
|
+
})
|
|
976
|
+
},
|
|
977
|
+
error => {
|
|
978
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
979
|
+
}
|
|
980
|
+
)
|
|
804
981
|
}
|
|
805
982
|
|
|
806
|
-
userStorageDelete = (args: UserStorageDeleteArgs, headers?: object): Promise<UserStorageDeleteReturn> => {
|
|
807
|
-
return this.fetch(this.url('UserStorageDelete'), createHTTPRequest(args, headers)).then(
|
|
808
|
-
|
|
809
|
-
return {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
983
|
+
userStorageDelete = (args: UserStorageDeleteArgs, headers?: object, signal?: AbortSignal): Promise<UserStorageDeleteReturn> => {
|
|
984
|
+
return this.fetch(this.url('UserStorageDelete'), createHTTPRequest(args, headers, signal)).then(
|
|
985
|
+
res => {
|
|
986
|
+
return buildResponse(res).then(_data => {
|
|
987
|
+
return {
|
|
988
|
+
ok: <boolean>_data.ok
|
|
989
|
+
}
|
|
990
|
+
})
|
|
991
|
+
},
|
|
992
|
+
error => {
|
|
993
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
994
|
+
}
|
|
995
|
+
)
|
|
814
996
|
}
|
|
815
997
|
|
|
816
|
-
userStorageFetchAll = (
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
998
|
+
userStorageFetchAll = (
|
|
999
|
+
args: UserStorageFetchAllArgs,
|
|
1000
|
+
headers?: object,
|
|
1001
|
+
signal?: AbortSignal
|
|
1002
|
+
): Promise<UserStorageFetchAllReturn> => {
|
|
1003
|
+
return this.fetch(this.url('UserStorageFetchAll'), createHTTPRequest(args, headers, signal)).then(
|
|
1004
|
+
res => {
|
|
1005
|
+
return buildResponse(res).then(_data => {
|
|
1006
|
+
return {
|
|
1007
|
+
objects: <{ [key: string]: any }>_data.objects
|
|
1008
|
+
}
|
|
1009
|
+
})
|
|
1010
|
+
},
|
|
1011
|
+
error => {
|
|
1012
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1013
|
+
}
|
|
1014
|
+
)
|
|
824
1015
|
}
|
|
825
1016
|
|
|
826
|
-
getMoonpayLink = (args: GetMoonpayLinkArgs, headers?: object): Promise<GetMoonpayLinkReturn> => {
|
|
827
|
-
return this.fetch(this.url('GetMoonpayLink'), createHTTPRequest(args, headers)).then(
|
|
828
|
-
|
|
829
|
-
return {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
1017
|
+
getMoonpayLink = (args: GetMoonpayLinkArgs, headers?: object, signal?: AbortSignal): Promise<GetMoonpayLinkReturn> => {
|
|
1018
|
+
return this.fetch(this.url('GetMoonpayLink'), createHTTPRequest(args, headers, signal)).then(
|
|
1019
|
+
res => {
|
|
1020
|
+
return buildResponse(res).then(_data => {
|
|
1021
|
+
return {
|
|
1022
|
+
signedUrl: <string>_data.signedUrl
|
|
1023
|
+
}
|
|
1024
|
+
})
|
|
1025
|
+
},
|
|
1026
|
+
error => {
|
|
1027
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1028
|
+
}
|
|
1029
|
+
)
|
|
834
1030
|
}
|
|
835
1031
|
|
|
836
|
-
getSardineClientToken = (headers?: object): Promise<GetSardineClientTokenReturn> => {
|
|
837
|
-
return this.fetch(this.url('GetSardineClientToken'), createHTTPRequest({}, headers)).then(
|
|
838
|
-
|
|
839
|
-
return {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
1032
|
+
getSardineClientToken = (headers?: object, signal?: AbortSignal): Promise<GetSardineClientTokenReturn> => {
|
|
1033
|
+
return this.fetch(this.url('GetSardineClientToken'), createHTTPRequest({}, headers, signal)).then(
|
|
1034
|
+
res => {
|
|
1035
|
+
return buildResponse(res).then(_data => {
|
|
1036
|
+
return {
|
|
1037
|
+
token: <string>_data.token
|
|
1038
|
+
}
|
|
1039
|
+
})
|
|
1040
|
+
},
|
|
1041
|
+
error => {
|
|
1042
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1043
|
+
}
|
|
1044
|
+
)
|
|
844
1045
|
}
|
|
845
1046
|
|
|
846
1047
|
getSardineNFTCheckoutToken = (
|
|
847
1048
|
args: GetSardineNFTCheckoutTokenArgs,
|
|
848
|
-
headers?: object
|
|
1049
|
+
headers?: object,
|
|
1050
|
+
signal?: AbortSignal
|
|
849
1051
|
): Promise<GetSardineNFTCheckoutTokenReturn> => {
|
|
850
|
-
return this.fetch(this.url('GetSardineNFTCheckoutToken'), createHTTPRequest(args, headers)).then(
|
|
851
|
-
|
|
852
|
-
return {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
1052
|
+
return this.fetch(this.url('GetSardineNFTCheckoutToken'), createHTTPRequest(args, headers, signal)).then(
|
|
1053
|
+
res => {
|
|
1054
|
+
return buildResponse(res).then(_data => {
|
|
1055
|
+
return {
|
|
1056
|
+
resp: <NftCheckout>_data.resp
|
|
1057
|
+
}
|
|
1058
|
+
})
|
|
1059
|
+
},
|
|
1060
|
+
error => {
|
|
1061
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1062
|
+
}
|
|
1063
|
+
)
|
|
857
1064
|
}
|
|
858
1065
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
1066
|
+
getSardineNFTCheckoutOrderStatus = (
|
|
1067
|
+
args: GetSardineNFTCheckoutOrderStatusArgs,
|
|
1068
|
+
headers?: object,
|
|
1069
|
+
signal?: AbortSignal
|
|
1070
|
+
): Promise<GetSardineNFTCheckoutOrderStatusReturn> => {
|
|
1071
|
+
return this.fetch(this.url('GetSardineNFTCheckoutOrderStatus'), createHTTPRequest(args, headers, signal)).then(
|
|
1072
|
+
res => {
|
|
1073
|
+
return buildResponse(res).then(_data => {
|
|
1074
|
+
return {
|
|
1075
|
+
resp: <SardineOrder>_data.resp
|
|
1076
|
+
}
|
|
1077
|
+
})
|
|
1078
|
+
},
|
|
1079
|
+
error => {
|
|
1080
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1081
|
+
}
|
|
1082
|
+
)
|
|
868
1083
|
}
|
|
869
1084
|
|
|
870
|
-
|
|
871
|
-
return this.fetch(this.url('
|
|
872
|
-
|
|
873
|
-
return {
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
1085
|
+
resolveENSAddress = (args: ResolveENSAddressArgs, headers?: object, signal?: AbortSignal): Promise<ResolveENSAddressReturn> => {
|
|
1086
|
+
return this.fetch(this.url('ResolveENSAddress'), createHTTPRequest(args, headers, signal)).then(
|
|
1087
|
+
res => {
|
|
1088
|
+
return buildResponse(res).then(_data => {
|
|
1089
|
+
return {
|
|
1090
|
+
address: <string>_data.address,
|
|
1091
|
+
ok: <boolean>_data.ok
|
|
1092
|
+
}
|
|
1093
|
+
})
|
|
1094
|
+
},
|
|
1095
|
+
error => {
|
|
1096
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1097
|
+
}
|
|
1098
|
+
)
|
|
878
1099
|
}
|
|
879
1100
|
|
|
880
|
-
|
|
881
|
-
return this.fetch(this.url('
|
|
882
|
-
|
|
883
|
-
return {
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
1101
|
+
isValidSignature = (args: IsValidSignatureArgs, headers?: object, signal?: AbortSignal): Promise<IsValidSignatureReturn> => {
|
|
1102
|
+
return this.fetch(this.url('IsValidSignature'), createHTTPRequest(args, headers, signal)).then(
|
|
1103
|
+
res => {
|
|
1104
|
+
return buildResponse(res).then(_data => {
|
|
1105
|
+
return {
|
|
1106
|
+
isValid: <boolean>_data.isValid
|
|
1107
|
+
}
|
|
1108
|
+
})
|
|
1109
|
+
},
|
|
1110
|
+
error => {
|
|
1111
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1112
|
+
}
|
|
1113
|
+
)
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
isValidMessageSignature = (
|
|
1117
|
+
args: IsValidMessageSignatureArgs,
|
|
1118
|
+
headers?: object,
|
|
1119
|
+
signal?: AbortSignal
|
|
1120
|
+
): Promise<IsValidMessageSignatureReturn> => {
|
|
1121
|
+
return this.fetch(this.url('IsValidMessageSignature'), createHTTPRequest(args, headers, signal)).then(
|
|
1122
|
+
res => {
|
|
1123
|
+
return buildResponse(res).then(_data => {
|
|
1124
|
+
return {
|
|
1125
|
+
isValid: <boolean>_data.isValid
|
|
1126
|
+
}
|
|
1127
|
+
})
|
|
1128
|
+
},
|
|
1129
|
+
error => {
|
|
1130
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1131
|
+
}
|
|
1132
|
+
)
|
|
888
1133
|
}
|
|
889
1134
|
|
|
890
1135
|
isValidTypedDataSignature = (
|
|
891
1136
|
args: IsValidTypedDataSignatureArgs,
|
|
892
|
-
headers?: object
|
|
1137
|
+
headers?: object,
|
|
1138
|
+
signal?: AbortSignal
|
|
893
1139
|
): Promise<IsValidTypedDataSignatureReturn> => {
|
|
894
|
-
return this.fetch(this.url('IsValidTypedDataSignature'), createHTTPRequest(args, headers)).then(
|
|
895
|
-
|
|
896
|
-
return {
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1140
|
+
return this.fetch(this.url('IsValidTypedDataSignature'), createHTTPRequest(args, headers, signal)).then(
|
|
1141
|
+
res => {
|
|
1142
|
+
return buildResponse(res).then(_data => {
|
|
1143
|
+
return {
|
|
1144
|
+
isValid: <boolean>_data.isValid
|
|
1145
|
+
}
|
|
1146
|
+
})
|
|
1147
|
+
},
|
|
1148
|
+
error => {
|
|
1149
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1150
|
+
}
|
|
1151
|
+
)
|
|
901
1152
|
}
|
|
902
1153
|
|
|
903
|
-
isValidETHAuthProof = (
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
1154
|
+
isValidETHAuthProof = (
|
|
1155
|
+
args: IsValidETHAuthProofArgs,
|
|
1156
|
+
headers?: object,
|
|
1157
|
+
signal?: AbortSignal
|
|
1158
|
+
): Promise<IsValidETHAuthProofReturn> => {
|
|
1159
|
+
return this.fetch(this.url('IsValidETHAuthProof'), createHTTPRequest(args, headers, signal)).then(
|
|
1160
|
+
res => {
|
|
1161
|
+
return buildResponse(res).then(_data => {
|
|
1162
|
+
return {
|
|
1163
|
+
isValid: <boolean>_data.isValid
|
|
1164
|
+
}
|
|
1165
|
+
})
|
|
1166
|
+
},
|
|
1167
|
+
error => {
|
|
1168
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1169
|
+
}
|
|
1170
|
+
)
|
|
911
1171
|
}
|
|
912
1172
|
|
|
913
|
-
getCoinPrices = (args: GetCoinPricesArgs, headers?: object): Promise<GetCoinPricesReturn> => {
|
|
914
|
-
return this.fetch(this.url('GetCoinPrices'), createHTTPRequest(args, headers)).then(
|
|
915
|
-
|
|
916
|
-
return {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
1173
|
+
getCoinPrices = (args: GetCoinPricesArgs, headers?: object, signal?: AbortSignal): Promise<GetCoinPricesReturn> => {
|
|
1174
|
+
return this.fetch(this.url('GetCoinPrices'), createHTTPRequest(args, headers, signal)).then(
|
|
1175
|
+
res => {
|
|
1176
|
+
return buildResponse(res).then(_data => {
|
|
1177
|
+
return {
|
|
1178
|
+
tokenPrices: <Array<TokenPrice>>_data.tokenPrices
|
|
1179
|
+
}
|
|
1180
|
+
})
|
|
1181
|
+
},
|
|
1182
|
+
error => {
|
|
1183
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1184
|
+
}
|
|
1185
|
+
)
|
|
921
1186
|
}
|
|
922
1187
|
|
|
923
|
-
getCollectiblePrices = (
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1188
|
+
getCollectiblePrices = (
|
|
1189
|
+
args: GetCollectiblePricesArgs,
|
|
1190
|
+
headers?: object,
|
|
1191
|
+
signal?: AbortSignal
|
|
1192
|
+
): Promise<GetCollectiblePricesReturn> => {
|
|
1193
|
+
return this.fetch(this.url('GetCollectiblePrices'), createHTTPRequest(args, headers, signal)).then(
|
|
1194
|
+
res => {
|
|
1195
|
+
return buildResponse(res).then(_data => {
|
|
1196
|
+
return {
|
|
1197
|
+
tokenPrices: <Array<TokenPrice>>_data.tokenPrices
|
|
1198
|
+
}
|
|
1199
|
+
})
|
|
1200
|
+
},
|
|
1201
|
+
error => {
|
|
1202
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1203
|
+
}
|
|
1204
|
+
)
|
|
931
1205
|
}
|
|
932
1206
|
|
|
933
|
-
getExchangeRate = (args: GetExchangeRateArgs, headers?: object): Promise<GetExchangeRateReturn> => {
|
|
934
|
-
return this.fetch(this.url('GetExchangeRate'), createHTTPRequest(args, headers)).then(
|
|
935
|
-
|
|
936
|
-
return {
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1207
|
+
getExchangeRate = (args: GetExchangeRateArgs, headers?: object, signal?: AbortSignal): Promise<GetExchangeRateReturn> => {
|
|
1208
|
+
return this.fetch(this.url('GetExchangeRate'), createHTTPRequest(args, headers, signal)).then(
|
|
1209
|
+
res => {
|
|
1210
|
+
return buildResponse(res).then(_data => {
|
|
1211
|
+
return {
|
|
1212
|
+
exchangeRate: <ExchangeRate>_data.exchangeRate
|
|
1213
|
+
}
|
|
1214
|
+
})
|
|
1215
|
+
},
|
|
1216
|
+
error => {
|
|
1217
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1218
|
+
}
|
|
1219
|
+
)
|
|
941
1220
|
}
|
|
942
1221
|
|
|
943
|
-
memoryStore = (args: MemoryStoreArgs, headers?: object): Promise<MemoryStoreReturn> => {
|
|
944
|
-
return this.fetch(this.url('MemoryStore'), createHTTPRequest(args, headers)).then(
|
|
945
|
-
|
|
946
|
-
return {
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1222
|
+
memoryStore = (args: MemoryStoreArgs, headers?: object, signal?: AbortSignal): Promise<MemoryStoreReturn> => {
|
|
1223
|
+
return this.fetch(this.url('MemoryStore'), createHTTPRequest(args, headers, signal)).then(
|
|
1224
|
+
res => {
|
|
1225
|
+
return buildResponse(res).then(_data => {
|
|
1226
|
+
return {
|
|
1227
|
+
ok: <boolean>_data.ok
|
|
1228
|
+
}
|
|
1229
|
+
})
|
|
1230
|
+
},
|
|
1231
|
+
error => {
|
|
1232
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1233
|
+
}
|
|
1234
|
+
)
|
|
951
1235
|
}
|
|
952
1236
|
|
|
953
|
-
memoryLoad = (args: MemoryLoadArgs, headers?: object): Promise<MemoryLoadReturn> => {
|
|
954
|
-
return this.fetch(this.url('MemoryLoad'), createHTTPRequest(args, headers)).then(
|
|
955
|
-
|
|
956
|
-
return {
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1237
|
+
memoryLoad = (args: MemoryLoadArgs, headers?: object, signal?: AbortSignal): Promise<MemoryLoadReturn> => {
|
|
1238
|
+
return this.fetch(this.url('MemoryLoad'), createHTTPRequest(args, headers, signal)).then(
|
|
1239
|
+
res => {
|
|
1240
|
+
return buildResponse(res).then(_data => {
|
|
1241
|
+
return {
|
|
1242
|
+
value: <string>_data.value
|
|
1243
|
+
}
|
|
1244
|
+
})
|
|
1245
|
+
},
|
|
1246
|
+
error => {
|
|
1247
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1248
|
+
}
|
|
1249
|
+
)
|
|
961
1250
|
}
|
|
962
1251
|
|
|
963
|
-
getInviteInfo = (headers?: object): Promise<GetInviteInfoReturn> => {
|
|
964
|
-
return this.fetch(this.url('GetInviteInfo'), createHTTPRequest({}, headers)).then(
|
|
965
|
-
|
|
966
|
-
return {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
1252
|
+
getInviteInfo = (headers?: object, signal?: AbortSignal): Promise<GetInviteInfoReturn> => {
|
|
1253
|
+
return this.fetch(this.url('GetInviteInfo'), createHTTPRequest({}, headers, signal)).then(
|
|
1254
|
+
res => {
|
|
1255
|
+
return buildResponse(res).then(_data => {
|
|
1256
|
+
return {
|
|
1257
|
+
inviteInfo: <InviteInfo>_data.inviteInfo
|
|
1258
|
+
}
|
|
1259
|
+
})
|
|
1260
|
+
},
|
|
1261
|
+
error => {
|
|
1262
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1263
|
+
}
|
|
1264
|
+
)
|
|
971
1265
|
}
|
|
972
1266
|
|
|
973
|
-
isValidAccessCode = (args: IsValidAccessCodeArgs, headers?: object): Promise<IsValidAccessCodeReturn> => {
|
|
974
|
-
return this.fetch(this.url('IsValidAccessCode'), createHTTPRequest(args, headers)).then(
|
|
975
|
-
|
|
976
|
-
return {
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1267
|
+
isValidAccessCode = (args: IsValidAccessCodeArgs, headers?: object, signal?: AbortSignal): Promise<IsValidAccessCodeReturn> => {
|
|
1268
|
+
return this.fetch(this.url('IsValidAccessCode'), createHTTPRequest(args, headers, signal)).then(
|
|
1269
|
+
res => {
|
|
1270
|
+
return buildResponse(res).then(_data => {
|
|
1271
|
+
return {
|
|
1272
|
+
status: <boolean>_data.status
|
|
1273
|
+
}
|
|
1274
|
+
})
|
|
1275
|
+
},
|
|
1276
|
+
error => {
|
|
1277
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1278
|
+
}
|
|
1279
|
+
)
|
|
981
1280
|
}
|
|
982
1281
|
|
|
983
|
-
internalClaimAccessCode = (
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1282
|
+
internalClaimAccessCode = (
|
|
1283
|
+
args: InternalClaimAccessCodeArgs,
|
|
1284
|
+
headers?: object,
|
|
1285
|
+
signal?: AbortSignal
|
|
1286
|
+
): Promise<InternalClaimAccessCodeReturn> => {
|
|
1287
|
+
return this.fetch(this.url('InternalClaimAccessCode'), createHTTPRequest(args, headers, signal)).then(
|
|
1288
|
+
res => {
|
|
1289
|
+
return buildResponse(res).then(_data => {
|
|
1290
|
+
return {
|
|
1291
|
+
status: <boolean>_data.status
|
|
1292
|
+
}
|
|
1293
|
+
})
|
|
1294
|
+
},
|
|
1295
|
+
error => {
|
|
1296
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1297
|
+
}
|
|
1298
|
+
)
|
|
991
1299
|
}
|
|
992
1300
|
|
|
993
|
-
blockNumberAtTime = (args: BlockNumberAtTimeArgs, headers?: object): Promise<BlockNumberAtTimeReturn> => {
|
|
994
|
-
return this.fetch(this.url('BlockNumberAtTime'), createHTTPRequest(args, headers)).then(
|
|
995
|
-
|
|
996
|
-
return {
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1301
|
+
blockNumberAtTime = (args: BlockNumberAtTimeArgs, headers?: object, signal?: AbortSignal): Promise<BlockNumberAtTimeReturn> => {
|
|
1302
|
+
return this.fetch(this.url('BlockNumberAtTime'), createHTTPRequest(args, headers, signal)).then(
|
|
1303
|
+
res => {
|
|
1304
|
+
return buildResponse(res).then(_data => {
|
|
1305
|
+
return {
|
|
1306
|
+
blocks: <Array<number>>_data.blocks
|
|
1307
|
+
}
|
|
1308
|
+
})
|
|
1309
|
+
},
|
|
1310
|
+
error => {
|
|
1311
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1312
|
+
}
|
|
1313
|
+
)
|
|
1001
1314
|
}
|
|
1002
1315
|
|
|
1003
|
-
paperSessionSecret = (
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1316
|
+
paperSessionSecret = (
|
|
1317
|
+
args: PaperSessionSecretArgs,
|
|
1318
|
+
headers?: object,
|
|
1319
|
+
signal?: AbortSignal
|
|
1320
|
+
): Promise<PaperSessionSecretReturn> => {
|
|
1321
|
+
return this.fetch(this.url('PaperSessionSecret'), createHTTPRequest(args, headers, signal)).then(
|
|
1322
|
+
res => {
|
|
1323
|
+
return buildResponse(res).then(_data => {
|
|
1324
|
+
return {
|
|
1325
|
+
secret: <string>_data.secret
|
|
1326
|
+
}
|
|
1327
|
+
})
|
|
1328
|
+
},
|
|
1329
|
+
error => {
|
|
1330
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1331
|
+
}
|
|
1332
|
+
)
|
|
1011
1333
|
}
|
|
1012
1334
|
|
|
1013
|
-
paperSessionSecret2 = (
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1335
|
+
paperSessionSecret2 = (
|
|
1336
|
+
args: PaperSessionSecret2Args,
|
|
1337
|
+
headers?: object,
|
|
1338
|
+
signal?: AbortSignal
|
|
1339
|
+
): Promise<PaperSessionSecret2Return> => {
|
|
1340
|
+
return this.fetch(this.url('PaperSessionSecret2'), createHTTPRequest(args, headers, signal)).then(
|
|
1341
|
+
res => {
|
|
1342
|
+
return buildResponse(res).then(_data => {
|
|
1343
|
+
return {
|
|
1344
|
+
secret: <string>_data.secret
|
|
1345
|
+
}
|
|
1346
|
+
})
|
|
1347
|
+
},
|
|
1348
|
+
error => {
|
|
1349
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1350
|
+
}
|
|
1351
|
+
)
|
|
1021
1352
|
}
|
|
1022
1353
|
|
|
1023
|
-
linkWallet = (args: LinkWalletArgs, headers?: object): Promise<LinkWalletReturn> => {
|
|
1024
|
-
return this.fetch(this.url('LinkWallet'), createHTTPRequest(args, headers)).then(
|
|
1025
|
-
|
|
1026
|
-
return {
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1354
|
+
linkWallet = (args: LinkWalletArgs, headers?: object, signal?: AbortSignal): Promise<LinkWalletReturn> => {
|
|
1355
|
+
return this.fetch(this.url('LinkWallet'), createHTTPRequest(args, headers, signal)).then(
|
|
1356
|
+
res => {
|
|
1357
|
+
return buildResponse(res).then(_data => {
|
|
1358
|
+
return {
|
|
1359
|
+
status: <boolean>_data.status,
|
|
1360
|
+
linkedWalletAddress: <string>_data.linkedWalletAddress
|
|
1361
|
+
}
|
|
1362
|
+
})
|
|
1363
|
+
},
|
|
1364
|
+
error => {
|
|
1365
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1366
|
+
}
|
|
1367
|
+
)
|
|
1032
1368
|
}
|
|
1033
1369
|
|
|
1034
|
-
getLinkedWallets = (args: GetLinkedWalletsArgs, headers?: object): Promise<GetLinkedWalletsReturn> => {
|
|
1035
|
-
return this.fetch(this.url('GetLinkedWallets'), createHTTPRequest(args, headers)).then(
|
|
1036
|
-
|
|
1037
|
-
return {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1370
|
+
getLinkedWallets = (args: GetLinkedWalletsArgs, headers?: object, signal?: AbortSignal): Promise<GetLinkedWalletsReturn> => {
|
|
1371
|
+
return this.fetch(this.url('GetLinkedWallets'), createHTTPRequest(args, headers, signal)).then(
|
|
1372
|
+
res => {
|
|
1373
|
+
return buildResponse(res).then(_data => {
|
|
1374
|
+
return {
|
|
1375
|
+
linkedWallets: <Array<string>>_data.linkedWallets
|
|
1376
|
+
}
|
|
1377
|
+
})
|
|
1378
|
+
},
|
|
1379
|
+
error => {
|
|
1380
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1381
|
+
}
|
|
1382
|
+
)
|
|
1042
1383
|
}
|
|
1043
1384
|
}
|
|
1044
1385
|
|
|
1045
|
-
|
|
1046
|
-
code: string
|
|
1047
|
-
msg: string
|
|
1048
|
-
status: number
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
const createHTTPRequest = (body: object = {}, headers: object = {}): object => {
|
|
1386
|
+
const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => {
|
|
1052
1387
|
return {
|
|
1053
1388
|
method: 'POST',
|
|
1054
1389
|
headers: { ...headers, 'Content-Type': 'application/json' },
|
|
1055
|
-
body: JSON.stringify(body || {})
|
|
1390
|
+
body: JSON.stringify(body || {}),
|
|
1391
|
+
signal
|
|
1056
1392
|
}
|
|
1057
1393
|
}
|
|
1058
1394
|
|
|
@@ -1061,14 +1397,347 @@ const buildResponse = (res: Response): Promise<any> => {
|
|
|
1061
1397
|
let data
|
|
1062
1398
|
try {
|
|
1063
1399
|
data = JSON.parse(text)
|
|
1064
|
-
} catch (
|
|
1065
|
-
|
|
1400
|
+
} catch (error) {
|
|
1401
|
+
let message = ''
|
|
1402
|
+
if (error instanceof Error) {
|
|
1403
|
+
message = error.message
|
|
1404
|
+
}
|
|
1405
|
+
throw WebrpcBadResponseError.new({
|
|
1406
|
+
status: res.status,
|
|
1407
|
+
cause: `JSON.parse(): ${message}: response text: ${text}`
|
|
1408
|
+
})
|
|
1066
1409
|
}
|
|
1067
1410
|
if (!res.ok) {
|
|
1068
|
-
|
|
1411
|
+
const code: number = typeof data.code === 'number' ? data.code : 0
|
|
1412
|
+
throw (webrpcErrorByCode[code] || WebrpcError).new(data)
|
|
1069
1413
|
}
|
|
1070
1414
|
return data
|
|
1071
1415
|
})
|
|
1072
1416
|
}
|
|
1073
1417
|
|
|
1418
|
+
//
|
|
1419
|
+
// Errors
|
|
1420
|
+
//
|
|
1421
|
+
|
|
1422
|
+
export class WebrpcError extends Error {
|
|
1423
|
+
name: string
|
|
1424
|
+
code: number
|
|
1425
|
+
message: string
|
|
1426
|
+
status: number
|
|
1427
|
+
cause?: string
|
|
1428
|
+
|
|
1429
|
+
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
|
|
1430
|
+
msg: string
|
|
1431
|
+
|
|
1432
|
+
constructor(name: string, code: number, message: string, status: number, cause?: string) {
|
|
1433
|
+
super(message)
|
|
1434
|
+
this.name = name || 'WebrpcError'
|
|
1435
|
+
this.code = typeof code === 'number' ? code : 0
|
|
1436
|
+
this.message = message || `endpoint error ${this.code}`
|
|
1437
|
+
this.msg = this.message
|
|
1438
|
+
this.status = typeof status === 'number' ? status : 0
|
|
1439
|
+
this.cause = cause
|
|
1440
|
+
Object.setPrototypeOf(this, WebrpcError.prototype)
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
static new(payload: any): WebrpcError {
|
|
1444
|
+
return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause)
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
// Webrpc errors
|
|
1449
|
+
|
|
1450
|
+
export class WebrpcEndpointError extends WebrpcError {
|
|
1451
|
+
constructor(
|
|
1452
|
+
name: string = 'WebrpcEndpoint',
|
|
1453
|
+
code: number = 0,
|
|
1454
|
+
message: string = 'endpoint error',
|
|
1455
|
+
status: number = 0,
|
|
1456
|
+
cause?: string
|
|
1457
|
+
) {
|
|
1458
|
+
super(name, code, message, status, cause)
|
|
1459
|
+
Object.setPrototypeOf(this, WebrpcEndpointError.prototype)
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
export class WebrpcRequestFailedError extends WebrpcError {
|
|
1464
|
+
constructor(
|
|
1465
|
+
name: string = 'WebrpcRequestFailed',
|
|
1466
|
+
code: number = -1,
|
|
1467
|
+
message: string = 'request failed',
|
|
1468
|
+
status: number = 0,
|
|
1469
|
+
cause?: string
|
|
1470
|
+
) {
|
|
1471
|
+
super(name, code, message, status, cause)
|
|
1472
|
+
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype)
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
export class WebrpcBadRouteError extends WebrpcError {
|
|
1477
|
+
constructor(
|
|
1478
|
+
name: string = 'WebrpcBadRoute',
|
|
1479
|
+
code: number = -2,
|
|
1480
|
+
message: string = 'bad route',
|
|
1481
|
+
status: number = 0,
|
|
1482
|
+
cause?: string
|
|
1483
|
+
) {
|
|
1484
|
+
super(name, code, message, status, cause)
|
|
1485
|
+
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype)
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
export class WebrpcBadMethodError extends WebrpcError {
|
|
1490
|
+
constructor(
|
|
1491
|
+
name: string = 'WebrpcBadMethod',
|
|
1492
|
+
code: number = -3,
|
|
1493
|
+
message: string = 'bad method',
|
|
1494
|
+
status: number = 0,
|
|
1495
|
+
cause?: string
|
|
1496
|
+
) {
|
|
1497
|
+
super(name, code, message, status, cause)
|
|
1498
|
+
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype)
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
export class WebrpcBadRequestError extends WebrpcError {
|
|
1503
|
+
constructor(
|
|
1504
|
+
name: string = 'WebrpcBadRequest',
|
|
1505
|
+
code: number = -4,
|
|
1506
|
+
message: string = 'bad request',
|
|
1507
|
+
status: number = 0,
|
|
1508
|
+
cause?: string
|
|
1509
|
+
) {
|
|
1510
|
+
super(name, code, message, status, cause)
|
|
1511
|
+
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype)
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
export class WebrpcBadResponseError extends WebrpcError {
|
|
1516
|
+
constructor(
|
|
1517
|
+
name: string = 'WebrpcBadResponse',
|
|
1518
|
+
code: number = -5,
|
|
1519
|
+
message: string = 'bad response',
|
|
1520
|
+
status: number = 0,
|
|
1521
|
+
cause?: string
|
|
1522
|
+
) {
|
|
1523
|
+
super(name, code, message, status, cause)
|
|
1524
|
+
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype)
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
export class WebrpcServerPanicError extends WebrpcError {
|
|
1529
|
+
constructor(
|
|
1530
|
+
name: string = 'WebrpcServerPanic',
|
|
1531
|
+
code: number = -6,
|
|
1532
|
+
message: string = 'server panic',
|
|
1533
|
+
status: number = 0,
|
|
1534
|
+
cause?: string
|
|
1535
|
+
) {
|
|
1536
|
+
super(name, code, message, status, cause)
|
|
1537
|
+
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype)
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
export class WebrpcInternalErrorError extends WebrpcError {
|
|
1542
|
+
constructor(
|
|
1543
|
+
name: string = 'WebrpcInternalError',
|
|
1544
|
+
code: number = -7,
|
|
1545
|
+
message: string = 'internal error',
|
|
1546
|
+
status: number = 0,
|
|
1547
|
+
cause?: string
|
|
1548
|
+
) {
|
|
1549
|
+
super(name, code, message, status, cause)
|
|
1550
|
+
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype)
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
export class WebrpcClientDisconnectedError extends WebrpcError {
|
|
1555
|
+
constructor(
|
|
1556
|
+
name: string = 'WebrpcClientDisconnected',
|
|
1557
|
+
code: number = -8,
|
|
1558
|
+
message: string = 'client disconnected',
|
|
1559
|
+
status: number = 0,
|
|
1560
|
+
cause?: string
|
|
1561
|
+
) {
|
|
1562
|
+
super(name, code, message, status, cause)
|
|
1563
|
+
Object.setPrototypeOf(this, WebrpcClientDisconnectedError.prototype)
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
export class WebrpcStreamLostError extends WebrpcError {
|
|
1568
|
+
constructor(
|
|
1569
|
+
name: string = 'WebrpcStreamLost',
|
|
1570
|
+
code: number = -9,
|
|
1571
|
+
message: string = 'stream lost',
|
|
1572
|
+
status: number = 0,
|
|
1573
|
+
cause?: string
|
|
1574
|
+
) {
|
|
1575
|
+
super(name, code, message, status, cause)
|
|
1576
|
+
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype)
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
export class WebrpcStreamFinishedError extends WebrpcError {
|
|
1581
|
+
constructor(
|
|
1582
|
+
name: string = 'WebrpcStreamFinished',
|
|
1583
|
+
code: number = -10,
|
|
1584
|
+
message: string = 'stream finished',
|
|
1585
|
+
status: number = 0,
|
|
1586
|
+
cause?: string
|
|
1587
|
+
) {
|
|
1588
|
+
super(name, code, message, status, cause)
|
|
1589
|
+
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype)
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
// Schema errors
|
|
1594
|
+
|
|
1595
|
+
export class UnauthorizedError extends WebrpcError {
|
|
1596
|
+
constructor(
|
|
1597
|
+
name: string = 'Unauthorized',
|
|
1598
|
+
code: number = 1000,
|
|
1599
|
+
message: string = 'Unauthorized access',
|
|
1600
|
+
status: number = 0,
|
|
1601
|
+
cause?: string
|
|
1602
|
+
) {
|
|
1603
|
+
super(name, code, message, status, cause)
|
|
1604
|
+
Object.setPrototypeOf(this, UnauthorizedError.prototype)
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
export class PermissionDeniedError extends WebrpcError {
|
|
1609
|
+
constructor(
|
|
1610
|
+
name: string = 'PermissionDenied',
|
|
1611
|
+
code: number = 1001,
|
|
1612
|
+
message: string = 'Permission denied',
|
|
1613
|
+
status: number = 0,
|
|
1614
|
+
cause?: string
|
|
1615
|
+
) {
|
|
1616
|
+
super(name, code, message, status, cause)
|
|
1617
|
+
Object.setPrototypeOf(this, PermissionDeniedError.prototype)
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
export class SessionExpiredError extends WebrpcError {
|
|
1622
|
+
constructor(
|
|
1623
|
+
name: string = 'SessionExpired',
|
|
1624
|
+
code: number = 1002,
|
|
1625
|
+
message: string = 'Session expired',
|
|
1626
|
+
status: number = 0,
|
|
1627
|
+
cause?: string
|
|
1628
|
+
) {
|
|
1629
|
+
super(name, code, message, status, cause)
|
|
1630
|
+
Object.setPrototypeOf(this, SessionExpiredError.prototype)
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
export class AbortedError extends WebrpcError {
|
|
1635
|
+
constructor(
|
|
1636
|
+
name: string = 'Aborted',
|
|
1637
|
+
code: number = 1005,
|
|
1638
|
+
message: string = 'Request aborted',
|
|
1639
|
+
status: number = 0,
|
|
1640
|
+
cause?: string
|
|
1641
|
+
) {
|
|
1642
|
+
super(name, code, message, status, cause)
|
|
1643
|
+
Object.setPrototypeOf(this, AbortedError.prototype)
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
export class InvalidArgumentError extends WebrpcError {
|
|
1648
|
+
constructor(
|
|
1649
|
+
name: string = 'InvalidArgument',
|
|
1650
|
+
code: number = 2000,
|
|
1651
|
+
message: string = 'Invalid argument',
|
|
1652
|
+
status: number = 0,
|
|
1653
|
+
cause?: string
|
|
1654
|
+
) {
|
|
1655
|
+
super(name, code, message, status, cause)
|
|
1656
|
+
Object.setPrototypeOf(this, InvalidArgumentError.prototype)
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
export class UnavailableError extends WebrpcError {
|
|
1661
|
+
constructor(
|
|
1662
|
+
name: string = 'Unavailable',
|
|
1663
|
+
code: number = 2002,
|
|
1664
|
+
message: string = 'Unavailable resource',
|
|
1665
|
+
status: number = 0,
|
|
1666
|
+
cause?: string
|
|
1667
|
+
) {
|
|
1668
|
+
super(name, code, message, status, cause)
|
|
1669
|
+
Object.setPrototypeOf(this, UnavailableError.prototype)
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
export class QueryFailedError extends WebrpcError {
|
|
1674
|
+
constructor(
|
|
1675
|
+
name: string = 'QueryFailed',
|
|
1676
|
+
code: number = 2003,
|
|
1677
|
+
message: string = 'Query failed',
|
|
1678
|
+
status: number = 0,
|
|
1679
|
+
cause?: string
|
|
1680
|
+
) {
|
|
1681
|
+
super(name, code, message, status, cause)
|
|
1682
|
+
Object.setPrototypeOf(this, QueryFailedError.prototype)
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
export class NotFoundError extends WebrpcError {
|
|
1687
|
+
constructor(
|
|
1688
|
+
name: string = 'NotFound',
|
|
1689
|
+
code: number = 3000,
|
|
1690
|
+
message: string = 'Resource not found',
|
|
1691
|
+
status: number = 0,
|
|
1692
|
+
cause?: string
|
|
1693
|
+
) {
|
|
1694
|
+
super(name, code, message, status, cause)
|
|
1695
|
+
Object.setPrototypeOf(this, NotFoundError.prototype)
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
export enum errors {
|
|
1700
|
+
WebrpcEndpoint = 'WebrpcEndpoint',
|
|
1701
|
+
WebrpcRequestFailed = 'WebrpcRequestFailed',
|
|
1702
|
+
WebrpcBadRoute = 'WebrpcBadRoute',
|
|
1703
|
+
WebrpcBadMethod = 'WebrpcBadMethod',
|
|
1704
|
+
WebrpcBadRequest = 'WebrpcBadRequest',
|
|
1705
|
+
WebrpcBadResponse = 'WebrpcBadResponse',
|
|
1706
|
+
WebrpcServerPanic = 'WebrpcServerPanic',
|
|
1707
|
+
WebrpcInternalError = 'WebrpcInternalError',
|
|
1708
|
+
WebrpcClientDisconnected = 'WebrpcClientDisconnected',
|
|
1709
|
+
WebrpcStreamLost = 'WebrpcStreamLost',
|
|
1710
|
+
WebrpcStreamFinished = 'WebrpcStreamFinished',
|
|
1711
|
+
Unauthorized = 'Unauthorized',
|
|
1712
|
+
PermissionDenied = 'PermissionDenied',
|
|
1713
|
+
SessionExpired = 'SessionExpired',
|
|
1714
|
+
Aborted = 'Aborted',
|
|
1715
|
+
InvalidArgument = 'InvalidArgument',
|
|
1716
|
+
Unavailable = 'Unavailable',
|
|
1717
|
+
QueryFailed = 'QueryFailed',
|
|
1718
|
+
NotFound = 'NotFound'
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
const webrpcErrorByCode: { [code: number]: any } = {
|
|
1722
|
+
[0]: WebrpcEndpointError,
|
|
1723
|
+
[-1]: WebrpcRequestFailedError,
|
|
1724
|
+
[-2]: WebrpcBadRouteError,
|
|
1725
|
+
[-3]: WebrpcBadMethodError,
|
|
1726
|
+
[-4]: WebrpcBadRequestError,
|
|
1727
|
+
[-5]: WebrpcBadResponseError,
|
|
1728
|
+
[-6]: WebrpcServerPanicError,
|
|
1729
|
+
[-7]: WebrpcInternalErrorError,
|
|
1730
|
+
[-8]: WebrpcClientDisconnectedError,
|
|
1731
|
+
[-9]: WebrpcStreamLostError,
|
|
1732
|
+
[-10]: WebrpcStreamFinishedError,
|
|
1733
|
+
[1000]: UnauthorizedError,
|
|
1734
|
+
[1001]: PermissionDeniedError,
|
|
1735
|
+
[1002]: SessionExpiredError,
|
|
1736
|
+
[1005]: AbortedError,
|
|
1737
|
+
[2000]: InvalidArgumentError,
|
|
1738
|
+
[2002]: UnavailableError,
|
|
1739
|
+
[2003]: QueryFailedError,
|
|
1740
|
+
[3000]: NotFoundError
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1074
1743
|
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>
|