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