@1shotapi/client-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +162 -0
  2. package/dist/categories/chains.d.ts +21 -0
  3. package/dist/categories/chains.js +44 -0
  4. package/dist/categories/chains.js.map +1 -0
  5. package/dist/categories/contractEvents.d.ts +103 -0
  6. package/dist/categories/contractEvents.js +115 -0
  7. package/dist/categories/contractEvents.js.map +1 -0
  8. package/dist/categories/contractMethods.d.ts +377 -0
  9. package/dist/categories/contractMethods.js +317 -0
  10. package/dist/categories/contractMethods.js.map +1 -0
  11. package/dist/categories/structs.d.ts +40 -0
  12. package/dist/categories/structs.js +68 -0
  13. package/dist/categories/structs.js.map +1 -0
  14. package/dist/categories/transactions.d.ts +31 -0
  15. package/dist/categories/transactions.js +51 -0
  16. package/dist/categories/transactions.js.map +1 -0
  17. package/dist/categories/wallets.d.ts +167 -0
  18. package/dist/categories/wallets.js +238 -0
  19. package/dist/categories/wallets.js.map +1 -0
  20. package/dist/client.d.ts +22 -0
  21. package/dist/client.js +61 -0
  22. package/dist/client.js.map +1 -0
  23. package/dist/index.d.ts +17 -0
  24. package/dist/index.js +22 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/types/abi.d.ts +32 -0
  27. package/dist/types/abi.js +2 -0
  28. package/dist/types/abi.js.map +1 -0
  29. package/dist/types/chain.d.ts +26 -0
  30. package/dist/types/chain.js +2 -0
  31. package/dist/types/chain.js.map +1 -0
  32. package/dist/types/client.d.ts +13 -0
  33. package/dist/types/client.js +2 -0
  34. package/dist/types/client.js.map +1 -0
  35. package/dist/types/common.d.ts +8 -0
  36. package/dist/types/common.js +2 -0
  37. package/dist/types/common.js.map +1 -0
  38. package/dist/types/contract.d.ts +5 -0
  39. package/dist/types/contract.js +2 -0
  40. package/dist/types/contract.js.map +1 -0
  41. package/dist/types/contractEvent.d.ts +46 -0
  42. package/dist/types/contractEvent.js +2 -0
  43. package/dist/types/contractEvent.js.map +1 -0
  44. package/dist/types/contractMethod.d.ts +31 -0
  45. package/dist/types/contractMethod.js +2 -0
  46. package/dist/types/contractMethod.js.map +1 -0
  47. package/dist/types/struct.d.ts +8 -0
  48. package/dist/types/struct.js +2 -0
  49. package/dist/types/struct.js.map +1 -0
  50. package/dist/types/transaction.d.ts +12 -0
  51. package/dist/types/transaction.js +2 -0
  52. package/dist/types/transaction.js.map +1 -0
  53. package/dist/types/wallet.d.ts +30 -0
  54. package/dist/types/wallet.js +2 -0
  55. package/dist/types/wallet.js.map +1 -0
  56. package/dist/types.d.ts +11 -0
  57. package/dist/types.js +2 -0
  58. package/dist/types.js.map +1 -0
  59. package/dist/utils/webhook.d.ts +19 -0
  60. package/dist/utils/webhook.js +66 -0
  61. package/dist/utils/webhook.js.map +1 -0
  62. package/dist/validation/abi.d.ts +470 -0
  63. package/dist/validation/abi.js +99 -0
  64. package/dist/validation/abi.js.map +1 -0
  65. package/dist/validation/chain.d.ts +157 -0
  66. package/dist/validation/chain.js +71 -0
  67. package/dist/validation/chain.js.map +1 -0
  68. package/dist/validation/common.d.ts +17 -0
  69. package/dist/validation/common.js +16 -0
  70. package/dist/validation/common.js.map +1 -0
  71. package/dist/validation/contractEvent.d.ts +323 -0
  72. package/dist/validation/contractEvent.js +148 -0
  73. package/dist/validation/contractEvent.js.map +1 -0
  74. package/dist/validation/contractMethod.d.ts +2746 -0
  75. package/dist/validation/contractMethod.js +787 -0
  76. package/dist/validation/contractMethod.js.map +1 -0
  77. package/dist/validation/struct.d.ts +495 -0
  78. package/dist/validation/struct.js +291 -0
  79. package/dist/validation/struct.js.map +1 -0
  80. package/dist/validation/transaction.d.ts +359 -0
  81. package/dist/validation/transaction.js +206 -0
  82. package/dist/validation/transaction.js.map +1 -0
  83. package/dist/validation/wallet.d.ts +537 -0
  84. package/dist/validation/wallet.js +287 -0
  85. package/dist/validation/wallet.js.map +1 -0
  86. package/package.json +71 -0
package/dist/client.js ADDED
@@ -0,0 +1,61 @@
1
+ import { Chains } from "./categories/chains.js";
2
+ import { ContractEvents } from "./categories/contractEvents.js";
3
+ import { ContractMethods } from "./categories/contractMethods.js";
4
+ import { Structs } from "./categories/structs.js";
5
+ import { Transactions } from "./categories/transactions.js";
6
+ import { Wallets } from "./categories/wallets.js";
7
+ export class OneShotClient {
8
+ constructor(config) {
9
+ this.accessToken = null;
10
+ this.tokenExpiry = null;
11
+ this.config = {
12
+ ...config,
13
+ baseUrl: config.baseUrl || "https://api.1shotapi.com/v0",
14
+ };
15
+ this.transactions = new Transactions(this);
16
+ this.contractMethods = new ContractMethods(this);
17
+ this.wallets = new Wallets(this);
18
+ this.structs = new Structs(this);
19
+ this.chains = new Chains(this);
20
+ this.contractEvents = new ContractEvents(this);
21
+ }
22
+ async getAccessToken() {
23
+ if (this.accessToken && this.tokenExpiry && this.tokenExpiry > new Date()) {
24
+ return this.accessToken;
25
+ }
26
+ const response = await fetch(`${this.config.baseUrl}/token`, {
27
+ method: "POST",
28
+ headers: {
29
+ "Content-Type": "application/x-www-form-urlencoded",
30
+ },
31
+ body: new URLSearchParams({
32
+ grant_type: "client_credentials",
33
+ client_id: this.config.apiKey,
34
+ client_secret: this.config.apiSecret,
35
+ }),
36
+ });
37
+ if (!response.ok) {
38
+ throw new Error(`Failed to get access token: ${response.statusText}`);
39
+ }
40
+ const data = await response.json();
41
+ this.accessToken = data.access_token;
42
+ this.tokenExpiry = new Date(Date.now() + data.expires_in * 1000);
43
+ return this.accessToken;
44
+ }
45
+ async request(method, path, body) {
46
+ const token = await this.getAccessToken();
47
+ const response = await fetch(`${this.config.baseUrl}${path}`, {
48
+ method,
49
+ headers: {
50
+ Authorization: `Bearer ${token}`,
51
+ "Content-Type": "application/json",
52
+ },
53
+ body: body ? JSON.stringify(body) : undefined,
54
+ });
55
+ if (!response.ok) {
56
+ throw new Error(`API request failed: ${response.statusText}`);
57
+ }
58
+ return response.json();
59
+ }
60
+ }
61
+ //# sourceMappingURL=client.js.map
@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E,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,uBAAuB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ export * from "./client.js";
2
+ export * from "./types/abi.js";
3
+ export * from "./types/chain.js";
4
+ export * from "./types/common.js";
5
+ export * from "./types/contract.js";
6
+ export * from "./types/transaction.js";
7
+ export * from "./types/struct.js";
8
+ export * from "./types/contractMethod.js";
9
+ export * from "./types/wallet.js";
10
+ export * from "./validation/abi.js";
11
+ export * from "./validation/chain.js";
12
+ export * from "./validation/common.js";
13
+ export * from "./validation/transaction.js";
14
+ export * from "./validation/struct.js";
15
+ export * from "./validation/contractMethod.js";
16
+ export * from "./validation/wallet.js";
17
+ export * from "./utils/webhook.js";
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ // Client exports
2
+ export * from "./client.js";
3
+ // Type exports
4
+ export * from "./types/abi.js";
5
+ export * from "./types/chain.js";
6
+ export * from "./types/common.js";
7
+ export * from "./types/contract.js";
8
+ export * from "./types/transaction.js";
9
+ export * from "./types/struct.js";
10
+ export * from "./types/contractMethod.js";
11
+ export * from "./types/wallet.js";
12
+ // Validation exports
13
+ export * from "./validation/abi.js";
14
+ export * from "./validation/chain.js";
15
+ export * from "./validation/common.js";
16
+ export * from "./validation/transaction.js";
17
+ export * from "./validation/struct.js";
18
+ export * from "./validation/contractMethod.js";
19
+ export * from "./validation/wallet.js";
20
+ // Utility exports
21
+ export * from "./utils/webhook.js";
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,cAAc,aAAa,CAAC;AAE5B,eAAe;AACf,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAElC,qBAAqB;AACrB,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AAEvC,kBAAkB;AAClB,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { z } from "zod";
2
+ import { abiParameterSchema, abiFunctionSchema, abiEventSchema, abiConstructorSchema, abiFallbackSchema, ethereumAbiSchema } from "../validation/abi.js";
3
+ /**
4
+ * Represents a parameter in an Ethereum ABI.
5
+ * This type is used to define function parameters, event parameters, and struct fields.
6
+ */
7
+ export type AbiParameter = z.infer<typeof abiParameterSchema>;
8
+ /**
9
+ * Represents a function in an Ethereum ABI.
10
+ * This type defines the structure of a smart contract function.
11
+ */
12
+ export type AbiFunction = z.infer<typeof abiFunctionSchema>;
13
+ /**
14
+ * Represents an event in an Ethereum ABI.
15
+ * This type defines the structure of a smart contract event.
16
+ */
17
+ export type AbiEvent = z.infer<typeof abiEventSchema>;
18
+ /**
19
+ * Represents a constructor in an Ethereum ABI.
20
+ * This type defines the structure of a smart contract constructor.
21
+ */
22
+ export type AbiConstructor = z.infer<typeof abiConstructorSchema>;
23
+ /**
24
+ * Represents a fallback function in an Ethereum ABI.
25
+ * This type defines the structure of a smart contract fallback function.
26
+ */
27
+ export type AbiFallback = z.infer<typeof abiFallbackSchema>;
28
+ /**
29
+ * Represents a complete Ethereum ABI.
30
+ * This type is an array of function, event, constructor, and fallback definitions.
31
+ */
32
+ export type EthereumAbi = z.infer<typeof ethereumAbiSchema>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=abi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi.js","sourceRoot":"","sources":["../../src/types/abi.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ import { chainInfoSchema, chainListSchema, listChainsSchema, nativeCurrencyInformationSchema, gasFeesSchema, getFeesSchema } from "../validation/chain.js";
3
+ /**
4
+ * Represents information about a chain supported by 1Shot API.
5
+ */
6
+ export type ChainInfo = z.infer<typeof chainInfoSchema>;
7
+ /**
8
+ * Represents information about the native currency of a chain.
9
+ */
10
+ export type NativeCurrencyInformation = z.infer<typeof nativeCurrencyInformationSchema>;
11
+ /**
12
+ * Represents current gas fees for a blockchain.
13
+ */
14
+ export type GasFees = z.infer<typeof gasFeesSchema>;
15
+ /**
16
+ * Represents a paginated list of chains.
17
+ */
18
+ export type ChainList = z.infer<typeof chainListSchema>;
19
+ /**
20
+ * Parameters for listing chains.
21
+ */
22
+ export type ListChains = z.infer<typeof listChainsSchema>;
23
+ /**
24
+ * Parameters for getting gas fees for a specific chain.
25
+ */
26
+ export type GetFees = z.infer<typeof getFeesSchema>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../src/types/chain.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Interface for the OneShot API client
3
+ */
4
+ export interface IOneShotClient {
5
+ /**
6
+ * Make a request to the OneShot API
7
+ * @param method HTTP method
8
+ * @param path API endpoint path
9
+ * @param body Optional request body
10
+ * @returns Promise with the response data
11
+ */
12
+ request<T>(method: string, path: string, body?: unknown): Promise<T>;
13
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/types/client.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ import { pagedResponseSchema } from "../validation/common.js";
3
+ /**
4
+ * Represents a paged response from the API.
5
+ * This type is used for endpoints that return paginated results.
6
+ * @template T The type of items in the response array
7
+ */
8
+ export type PagedResponse<T> = z.infer<ReturnType<typeof pagedResponseSchema<T>>>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ import { contractFunctionPromptSchema, promptSchema, fullPromptSchema } from "../validation/contractMethod.js";
3
+ export type ContractFunctionPrompt = z.infer<typeof contractFunctionPromptSchema>;
4
+ export type Prompt = z.infer<typeof promptSchema>;
5
+ export type FullPrompt = z.infer<typeof fullPromptSchema>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/types/contract.ts"],"names":[],"mappings":""}
@@ -0,0 +1,46 @@
1
+ import { z } from "zod";
2
+ import { topicSchema, contractEventLogSchema, contractEventSchema, contractEventListSchema, createContractEventSchema, listContractEventsSchema, getContractEventSchema, updateContractEventSchema, deleteContractEventSchema, searchContractEventLogsSchema, contractEventSearchResultSchema } from "../validation/contractEvent.js";
3
+ /**
4
+ * Represents a topic parameter for a contract event.
5
+ */
6
+ export type Topic = z.infer<typeof topicSchema>;
7
+ /**
8
+ * Represents a contract event log from the blockchain.
9
+ */
10
+ export type ContractEventLog = z.infer<typeof contractEventLogSchema>;
11
+ /**
12
+ * Represents a contract event definition for monitoring blockchain events.
13
+ */
14
+ export type ContractEvent = z.infer<typeof contractEventSchema>;
15
+ /**
16
+ * Represents a paginated list of contract events.
17
+ */
18
+ export type ContractEventList = z.infer<typeof contractEventListSchema>;
19
+ /**
20
+ * Parameters for creating a new contract event definition.
21
+ */
22
+ export type CreateContractEvent = z.infer<typeof createContractEventSchema>;
23
+ /**
24
+ * Parameters for listing contract events.
25
+ */
26
+ export type ListContractEvents = z.infer<typeof listContractEventsSchema>;
27
+ /**
28
+ * Parameters for getting a contract event.
29
+ */
30
+ export type GetContractEvent = z.infer<typeof getContractEventSchema>;
31
+ /**
32
+ * Parameters for updating a contract event.
33
+ */
34
+ export type UpdateContractEvent = z.infer<typeof updateContractEventSchema>;
35
+ /**
36
+ * Parameters for deleting a contract event.
37
+ */
38
+ export type DeleteContractEvent = z.infer<typeof deleteContractEventSchema>;
39
+ /**
40
+ * Parameters for searching contract event logs.
41
+ */
42
+ export type SearchContractEventLogs = z.infer<typeof searchContractEventLogsSchema>;
43
+ /**
44
+ * Results from searching contract event logs.
45
+ */
46
+ export type ContractEventSearchResult = z.infer<typeof contractEventSearchResultSchema>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=contractEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contractEvent.js","sourceRoot":"","sources":["../../src/types/contractEvent.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ import { contractMethodStateMutabilitySchema, contractMethodStatusSchema, contractMethodParamsSchema, contractMethodEstimateSchema, contractMethodUpdateSchema, contractMethodSchema, contractMethodListSchema, listContractMethodsSchema, executeContractMethodSchema, executeAsDelegatorContractMethodSchema, batchContractMethodSchema, batchContractMethodAsDelegatorSchema, executeBatchContractMethodSchema, executeBatchAsDelegatorContractMethodSchema, testContractMethodSchema, getContractMethodSchema, estimateContractMethodSchema, readContractMethodSchema, createContractMethodSchema, importFromABISchema, updateContractMethodSchema, deleteContractMethodSchema, restoreContractMethodSchema, contractFunctionParamDescriptionSchema, contractSearchSchema, contractContractMethodsSchema, contractMethodTestResultSchema, contractMethodEncodeResultSchema, erc7702AuthorizationSchema } from "../validation/contractMethod.js";
3
+ export type ContractMethodStateMutability = z.infer<typeof contractMethodStateMutabilitySchema>;
4
+ export type ContractMethodStatus = z.infer<typeof contractMethodStatusSchema>;
5
+ export type ContractMethodParams = z.infer<typeof contractMethodParamsSchema>;
6
+ export type ContractMethodEstimate = z.infer<typeof contractMethodEstimateSchema>;
7
+ export type ContractMethodUpdate = z.infer<typeof contractMethodUpdateSchema>;
8
+ export type ContractMethod = z.infer<typeof contractMethodSchema>;
9
+ export type ContractMethodList = z.infer<typeof contractMethodListSchema>;
10
+ export type ListContractMethods = z.infer<typeof listContractMethodsSchema>;
11
+ export type ExecuteContractMethod = z.infer<typeof executeContractMethodSchema>;
12
+ export type ExecuteAsDelegatorContractMethod = z.infer<typeof executeAsDelegatorContractMethodSchema>;
13
+ export type BatchContractMethod = z.infer<typeof batchContractMethodSchema>;
14
+ export type BatchContractMethodAsDelegator = z.infer<typeof batchContractMethodAsDelegatorSchema>;
15
+ export type ExecuteBatchContractMethod = z.infer<typeof executeBatchContractMethodSchema>;
16
+ export type ExecuteBatchAsDelegatorContractMethod = z.infer<typeof executeBatchAsDelegatorContractMethodSchema>;
17
+ export type TestContractMethod = z.infer<typeof testContractMethodSchema>;
18
+ export type GetContractMethod = z.infer<typeof getContractMethodSchema>;
19
+ export type EstimateContractMethod = z.infer<typeof estimateContractMethodSchema>;
20
+ export type ReadContractMethod = z.infer<typeof readContractMethodSchema>;
21
+ export type CreateContractMethod = z.infer<typeof createContractMethodSchema>;
22
+ export type ImportFromABI = z.infer<typeof importFromABISchema>;
23
+ export type UpdateContractMethod = z.infer<typeof updateContractMethodSchema>;
24
+ export type DeleteContractMethod = z.infer<typeof deleteContractMethodSchema>;
25
+ export type RestoreContractMethod = z.infer<typeof restoreContractMethodSchema>;
26
+ export type ContractFunctionParamDescription = z.infer<typeof contractFunctionParamDescriptionSchema>;
27
+ export type ContractSearch = z.infer<typeof contractSearchSchema>;
28
+ export type ContractContractMethods = z.infer<typeof contractContractMethodsSchema>;
29
+ export type ContractMethodTestResult = z.infer<typeof contractMethodTestResultSchema>;
30
+ export type ContractMethodEncodeResult = z.infer<typeof contractMethodEncodeResultSchema>;
31
+ export type ERC7702Authorization = z.infer<typeof erc7702AuthorizationSchema>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=contractMethod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contractMethod.js","sourceRoot":"","sources":["../../src/types/contractMethod.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ import { newSolidityStructParamSchema, solidityStructParamSchema, solidityStructSchema, structUpdateSchema, solidityStructParamUpdateSchema, updateStructParamsSchema } from "../validation/struct.js";
3
+ export type SolidityStructParamUpdate = z.infer<typeof solidityStructParamUpdateSchema>;
4
+ export type NewSolidityStructParam = z.infer<typeof newSolidityStructParamSchema>;
5
+ export type SolidityStructParam = z.infer<typeof solidityStructParamSchema>;
6
+ export type SolidityStruct = z.infer<typeof solidityStructSchema>;
7
+ export type StructUpdate = z.infer<typeof structUpdateSchema>;
8
+ export type SolidityStructParamUpdateRequest = z.infer<typeof updateStructParamsSchema>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=struct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"struct.js","sourceRoot":"","sources":["../../src/types/struct.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+ import { transactionSchema, logDescriptionSchema } from "../validation/transaction.js";
3
+ /**
4
+ * Represents the execution of a transaction in the 1Shot API.
5
+ * This type tracks the status and details of a transaction.
6
+ */
7
+ export type Transaction = z.infer<typeof transactionSchema>;
8
+ /**
9
+ * Represents a log event emitted by a transaction.
10
+ * This type describes the details of a blockchain log event.
11
+ */
12
+ export type LogDescription = z.infer<typeof logDescriptionSchema>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/types/transaction.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ import { accountBalanceDetailsSchema, walletSchema, walletListSchema, walletUpdateSchema, walletCreateSchema, listWalletsSchema, createWalletSchema, getWalletSchema, updateWalletSchema, deleteWalletSchema, transferWalletSchema, delegationSchema, delegationListSchema, listDelegationsSchema, createDelegationSchema, getSignatureSchema, signatureResponseSchema } from "../validation/wallet.js";
3
+ /**
4
+ * Represents an escrow wallet in the 1Shot API.
5
+ * An escrow wallet is a wallet that the platform holds keys for.
6
+ */
7
+ export type Wallet = z.infer<typeof walletSchema>;
8
+ /**
9
+ * Represents the balance details of a token in a wallet.
10
+ */
11
+ export type AccountBalanceDetails = z.infer<typeof accountBalanceDetailsSchema>;
12
+ export type WalletList = z.infer<typeof walletListSchema>;
13
+ export type WalletUpdate = z.infer<typeof walletUpdateSchema>;
14
+ export type WalletCreate = z.infer<typeof walletCreateSchema>;
15
+ export type ListWallets = z.infer<typeof listWalletsSchema>;
16
+ export type CreateWallet = z.infer<typeof createWalletSchema>;
17
+ export type GetWallet = z.infer<typeof getWalletSchema>;
18
+ export type UpdateWallet = z.infer<typeof updateWalletSchema>;
19
+ export type DeleteWallet = z.infer<typeof deleteWalletSchema>;
20
+ export type TransferWallet = z.infer<typeof transferWalletSchema>;
21
+ /**
22
+ * Represents a delegation in the 1Shot API.
23
+ * A delegation allows a wallet to execute transactions on behalf of specified contract addresses and methods.
24
+ */
25
+ export type Delegation = z.infer<typeof delegationSchema>;
26
+ export type DelegationList = z.infer<typeof delegationListSchema>;
27
+ export type ListDelegations = z.infer<typeof listDelegationsSchema>;
28
+ export type CreateDelegation = z.infer<typeof createDelegationSchema>;
29
+ export type GetSignature = z.infer<typeof getSignatureSchema>;
30
+ export type SignatureResponse = z.infer<typeof signatureResponseSchema>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/types/wallet.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ export interface ClientConfig {
2
+ apiKey: string;
3
+ apiSecret: string;
4
+ baseUrl?: string;
5
+ }
6
+ export interface TokenResponse {
7
+ access_token: string;
8
+ token_type: string;
9
+ expires_in: number;
10
+ }
11
+ export * from "./categories/contractMethods";
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./categories/contractMethods";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAYA,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Validates a webhook signature using ED25519.
3
+ * This utility verifies that the webhook data was signed by the 1Shot API using the provided public key.
4
+ *
5
+ * @param data - The webhook data object (should include all fields except the signature)
6
+ * @param publicKey - The base64-encoded public key provided by 1Shot
7
+ * @returns boolean - True if the signature is valid, false otherwise
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const isValid = validateWebhook(webhookData, "SBLzVF0dHNo/6tXo3+UOsYnCJ3Brq/SNxAFOAMWxTVo=");
12
+ * if (isValid) {
13
+ * // Process the webhook
14
+ * } else {
15
+ * // Reject the webhook
16
+ * }
17
+ * ```
18
+ */
19
+ export declare function validateWebhook(data: Record<string, any>, publicKey: string): Promise<boolean>;
@@ -0,0 +1,66 @@
1
+ import { verify, etc } from "@noble/ed25519";
2
+ import { sha512 } from "@noble/hashes/sha512";
3
+ // Initialize the ed25519 library with SHA-512
4
+ etc.sha512Sync = (...m) => sha512(etc.concatBytes(...m));
5
+ /**
6
+ * Recursively sorts object keys alphabetically
7
+ * @param obj - The object to sort
8
+ * @returns A new object with sorted keys
9
+ */
10
+ function sortObjectKeys(obj) {
11
+ if (obj === null || typeof obj !== "object") {
12
+ return obj;
13
+ }
14
+ if (Array.isArray(obj)) {
15
+ return obj.map(sortObjectKeys);
16
+ }
17
+ return Object.keys(obj)
18
+ .sort()
19
+ .reduce((result, key) => {
20
+ result[key] = sortObjectKeys(obj[key]);
21
+ return result;
22
+ }, {});
23
+ }
24
+ /**
25
+ * Validates a webhook signature using ED25519.
26
+ * This utility verifies that the webhook data was signed by the 1Shot API using the provided public key.
27
+ *
28
+ * @param data - The webhook data object (should include all fields except the signature)
29
+ * @param publicKey - The base64-encoded public key provided by 1Shot
30
+ * @returns boolean - True if the signature is valid, false otherwise
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const isValid = validateWebhook(webhookData, "SBLzVF0dHNo/6tXo3+UOsYnCJ3Brq/SNxAFOAMWxTVo=");
35
+ * if (isValid) {
36
+ * // Process the webhook
37
+ * } else {
38
+ * // Reject the webhook
39
+ * }
40
+ * ```
41
+ */
42
+ export async function validateWebhook(data, publicKey) {
43
+ try {
44
+ // Extract the signature from the data
45
+ const { signature, ...dataWithoutSignature } = data;
46
+ if (signature == null) {
47
+ return false;
48
+ }
49
+ // Convert the public key from base64 to bytes
50
+ const publicKeyBytes = Buffer.from(publicKey, "base64");
51
+ // Convert the signature from base64 to bytes
52
+ const signatureBytes = Buffer.from(signature, "base64");
53
+ // Sort all object keys recursively and create a canonical JSON string
54
+ const sortedData = sortObjectKeys(dataWithoutSignature);
55
+ const message = JSON.stringify(sortedData);
56
+ // Convert the message to UTF-8 bytes
57
+ const messageBytes = new TextEncoder().encode(message);
58
+ // Verify the signature
59
+ return await verify(signatureBytes, messageBytes, publicKeyBytes);
60
+ }
61
+ catch (error) {
62
+ // If any error occurs during validation, return false
63
+ return false;
64
+ }
65
+ }
66
+ //# sourceMappingURL=webhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/utils/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,8CAA8C;AAC9C,GAAG,CAAC,UAAU,GAAG,CAAC,GAAG,CAAC,EAA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