@silvana-one/abi 0.1.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 (117) hide show
  1. package/README.md +1 -0
  2. package/dist/node/contracts.d.ts +17 -0
  3. package/dist/node/contracts.js +19 -0
  4. package/dist/node/contracts.js.map +1 -0
  5. package/dist/node/fee.d.ts +2 -0
  6. package/dist/node/fee.js +3 -0
  7. package/dist/node/fee.js.map +1 -0
  8. package/dist/node/fetch.d.ts +14 -0
  9. package/dist/node/fetch.js +59 -0
  10. package/dist/node/fetch.js.map +1 -0
  11. package/dist/node/index.cjs +1119 -0
  12. package/dist/node/index.d.ts +6 -0
  13. package/dist/node/index.js +7 -0
  14. package/dist/node/index.js.map +1 -0
  15. package/dist/node/info/address.d.ts +1 -0
  16. package/dist/node/info/address.js +20 -0
  17. package/dist/node/info/address.js.map +1 -0
  18. package/dist/node/info/index.d.ts +1 -0
  19. package/dist/node/info/index.js +2 -0
  20. package/dist/node/info/index.js.map +1 -0
  21. package/dist/node/token/build.d.ts +46 -0
  22. package/dist/node/token/build.js +789 -0
  23. package/dist/node/token/build.js.map +1 -0
  24. package/dist/node/token/contracts.d.ts +17 -0
  25. package/dist/node/token/contracts.js +13 -0
  26. package/dist/node/token/contracts.js.map +1 -0
  27. package/dist/node/token/index.d.ts +3 -0
  28. package/dist/node/token/index.js +4 -0
  29. package/dist/node/token/index.js.map +1 -0
  30. package/dist/node/token/info.d.ts +11 -0
  31. package/dist/node/token/info.js +528 -0
  32. package/dist/node/token/info.js.map +1 -0
  33. package/dist/node/types.d.ts +4 -0
  34. package/dist/node/types.js +2 -0
  35. package/dist/node/types.js.map +1 -0
  36. package/dist/node/vk/devnet.d.ts +2 -0
  37. package/dist/node/vk/devnet.js +86 -0
  38. package/dist/node/vk/devnet.js.map +1 -0
  39. package/dist/node/vk/index.d.ts +4 -0
  40. package/dist/node/vk/index.js +5 -0
  41. package/dist/node/vk/index.js.map +1 -0
  42. package/dist/node/vk/mainnet.d.ts +2 -0
  43. package/dist/node/vk/mainnet.js +86 -0
  44. package/dist/node/vk/mainnet.js.map +1 -0
  45. package/dist/node/vk/types.d.ts +10 -0
  46. package/dist/node/vk/types.js +2 -0
  47. package/dist/node/vk/types.js.map +1 -0
  48. package/dist/node/vk/vk.d.ts +2 -0
  49. package/dist/node/vk/vk.js +7 -0
  50. package/dist/node/vk/vk.js.map +1 -0
  51. package/dist/tsconfig.tsbuildinfo +1 -0
  52. package/dist/tsconfig.web.tsbuildinfo +1 -0
  53. package/dist/web/contracts.d.ts +17 -0
  54. package/dist/web/contracts.js +19 -0
  55. package/dist/web/contracts.js.map +1 -0
  56. package/dist/web/fee.d.ts +2 -0
  57. package/dist/web/fee.js +3 -0
  58. package/dist/web/fee.js.map +1 -0
  59. package/dist/web/fetch.d.ts +14 -0
  60. package/dist/web/fetch.js +59 -0
  61. package/dist/web/fetch.js.map +1 -0
  62. package/dist/web/index.d.ts +6 -0
  63. package/dist/web/index.js +7 -0
  64. package/dist/web/index.js.map +1 -0
  65. package/dist/web/info/address.d.ts +1 -0
  66. package/dist/web/info/address.js +20 -0
  67. package/dist/web/info/address.js.map +1 -0
  68. package/dist/web/info/index.d.ts +1 -0
  69. package/dist/web/info/index.js +2 -0
  70. package/dist/web/info/index.js.map +1 -0
  71. package/dist/web/token/build.d.ts +46 -0
  72. package/dist/web/token/build.js +789 -0
  73. package/dist/web/token/build.js.map +1 -0
  74. package/dist/web/token/contracts.d.ts +17 -0
  75. package/dist/web/token/contracts.js +13 -0
  76. package/dist/web/token/contracts.js.map +1 -0
  77. package/dist/web/token/index.d.ts +3 -0
  78. package/dist/web/token/index.js +4 -0
  79. package/dist/web/token/index.js.map +1 -0
  80. package/dist/web/token/info.d.ts +11 -0
  81. package/dist/web/token/info.js +528 -0
  82. package/dist/web/token/info.js.map +1 -0
  83. package/dist/web/types.d.ts +4 -0
  84. package/dist/web/types.js +2 -0
  85. package/dist/web/types.js.map +1 -0
  86. package/dist/web/vk/devnet.d.ts +2 -0
  87. package/dist/web/vk/devnet.js +86 -0
  88. package/dist/web/vk/devnet.js.map +1 -0
  89. package/dist/web/vk/index.d.ts +4 -0
  90. package/dist/web/vk/index.js +5 -0
  91. package/dist/web/vk/index.js.map +1 -0
  92. package/dist/web/vk/mainnet.d.ts +2 -0
  93. package/dist/web/vk/mainnet.js +86 -0
  94. package/dist/web/vk/mainnet.js.map +1 -0
  95. package/dist/web/vk/types.d.ts +10 -0
  96. package/dist/web/vk/types.js +2 -0
  97. package/dist/web/vk/types.js.map +1 -0
  98. package/dist/web/vk/vk.d.ts +2 -0
  99. package/dist/web/vk/vk.js +7 -0
  100. package/dist/web/vk/vk.js.map +1 -0
  101. package/package.json +69 -0
  102. package/src/contracts.ts +50 -0
  103. package/src/fee.ts +2 -0
  104. package/src/fetch.ts +73 -0
  105. package/src/index.ts +6 -0
  106. package/src/info/address.ts +25 -0
  107. package/src/info/index.ts +1 -0
  108. package/src/token/build.ts +1014 -0
  109. package/src/token/contracts.ts +40 -0
  110. package/src/token/index.ts +3 -0
  111. package/src/token/info.ts +600 -0
  112. package/src/types.ts +4 -0
  113. package/src/vk/devnet.ts +88 -0
  114. package/src/vk/index.ts +4 -0
  115. package/src/vk/mainnet.ts +88 -0
  116. package/src/vk/types.ts +16 -0
  117. package/src/vk/vk.ts +8 -0
package/src/fetch.ts ADDED
@@ -0,0 +1,73 @@
1
+ import { PublicKey, Field, fetchAccount, Account } from "o1js";
2
+
3
+ /**
4
+ * Fetches the Mina account for a given public key with error handling
5
+ * @param params the parameters for fetching the account
6
+ * @param params.publicKey the public key of the account
7
+ * @param params.tokenId the token id of the account
8
+ * @param params.force whether to force the fetch - use it only if you are sure the account exists
9
+ * @returns the account object
10
+ */
11
+ export async function fetchMinaAccount(params: {
12
+ publicKey: string | PublicKey;
13
+ tokenId?: string | Field | undefined;
14
+ force?: boolean;
15
+ }): Promise<Account | undefined> {
16
+ const { publicKey, tokenId, force = false } = params;
17
+ const timeout = 1000 * 60 * 3; // 3 minutes
18
+ let attempt = 0;
19
+ const startTime = Date.now();
20
+ let result = { account: undefined };
21
+ while (Date.now() - startTime < timeout) {
22
+ try {
23
+ const result = await fetchAccount({
24
+ publicKey,
25
+ tokenId,
26
+ });
27
+ return result.account;
28
+ } catch (error: any) {
29
+ if (force === true)
30
+ console.log("Error in fetchMinaAccount:", {
31
+ error,
32
+ publicKey:
33
+ typeof publicKey === "string" ? publicKey : publicKey.toBase58(),
34
+ tokenId: tokenId?.toString(),
35
+ force,
36
+ });
37
+ else {
38
+ console.log("fetchMinaAccount error", {
39
+ error,
40
+ publicKey:
41
+ typeof publicKey === "string" ? publicKey : publicKey.toBase58(),
42
+ tokenId: tokenId?.toString(),
43
+ force,
44
+ });
45
+ return result.account;
46
+ }
47
+ }
48
+ attempt++;
49
+ await sleep(1000 * 6 * attempt); // to handle rate limit we increase the interval
50
+ }
51
+ if (force === true)
52
+ throw new Error(
53
+ `fetchMinaAccount timeout
54
+ ${{
55
+ publicKey:
56
+ typeof publicKey === "string" ? publicKey : publicKey.toBase58(),
57
+ tokenId: tokenId?.toString(),
58
+ force,
59
+ }}`
60
+ );
61
+ else
62
+ console.log(
63
+ "fetchMinaAccount timeout",
64
+ typeof publicKey === "string" ? publicKey : publicKey.toBase58(),
65
+ tokenId?.toString(),
66
+ force
67
+ );
68
+ return result.account;
69
+ }
70
+
71
+ function sleep(ms: number) {
72
+ return new Promise((resolve) => setTimeout(resolve, ms));
73
+ }
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./fee.js";
2
+ export * from "./token/index.js";
3
+ export * from "./types.js";
4
+ export * from "./fetch.js";
5
+ export * from "./vk/index.js";
6
+ export * from "./info/index.js";
@@ -0,0 +1,25 @@
1
+ import { PublicKey } from "o1js";
2
+
3
+ export async function checkAddress(
4
+ address: string | undefined
5
+ ): Promise<boolean> {
6
+ if (!address || typeof address !== "string") {
7
+ console.error("checkAddress params are invalid:", address);
8
+ return false;
9
+ }
10
+ try {
11
+ const publicKey = PublicKey.fromBase58(address);
12
+ if (address !== publicKey.toBase58()) {
13
+ console.error(
14
+ "checkAddress: address is not valid",
15
+ address,
16
+ publicKey.toBase58()
17
+ );
18
+ return false;
19
+ }
20
+ return true;
21
+ } catch (error) {
22
+ console.error("checkAddress catch", { address, error });
23
+ return false;
24
+ }
25
+ }
@@ -0,0 +1 @@
1
+ export * from "./address.js";