@slvr-labs/sdk 0.1.0 → 0.1.2
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/README.md +42 -0
- package/dist/index.d.mts +2117 -0
- package/dist/index.d.ts +1903 -34
- package/dist/index.js +3091 -427
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3035 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +19 -11
- package/skills/slvr-bot/SKILL.md +9 -8
- package/skills/slvr-bot/references/api.md +8 -0
- package/dist/connect.d.ts +0 -47
- package/dist/connect.d.ts.map +0 -1
- package/dist/connect.js +0 -56
- package/dist/connect.js.map +0 -1
- package/dist/contracts/autoCommit.d.ts +0 -151
- package/dist/contracts/autoCommit.d.ts.map +0 -1
- package/dist/contracts/autoCommit.js +0 -426
- package/dist/contracts/autoCommit.js.map +0 -1
- package/dist/contracts/hub.d.ts +0 -50
- package/dist/contracts/hub.d.ts.map +0 -1
- package/dist/contracts/hub.js +0 -118
- package/dist/contracts/hub.js.map +0 -1
- package/dist/contracts/index.d.ts +0 -8
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/index.js +0 -18
- package/dist/contracts/index.js.map +0 -1
- package/dist/contracts/jackpot.d.ts +0 -21
- package/dist/contracts/jackpot.d.ts.map +0 -1
- package/dist/contracts/jackpot.js +0 -44
- package/dist/contracts/jackpot.js.map +0 -1
- package/dist/contracts/lottery.d.ts +0 -256
- package/dist/contracts/lottery.d.ts.map +0 -1
- package/dist/contracts/lottery.js +0 -767
- package/dist/contracts/lottery.js.map +0 -1
- package/dist/contracts/registry.d.ts +0 -53
- package/dist/contracts/registry.d.ts.map +0 -1
- package/dist/contracts/registry.js +0 -143
- package/dist/contracts/registry.js.map +0 -1
- package/dist/contracts/staking.d.ts +0 -101
- package/dist/contracts/staking.d.ts.map +0 -1
- package/dist/contracts/staking.js +0 -306
- package/dist/contracts/staking.js.map +0 -1
- package/dist/contracts/token.d.ts +0 -95
- package/dist/contracts/token.d.ts.map +0 -1
- package/dist/contracts/token.js +0 -273
- package/dist/contracts/token.js.map +0 -1
- package/dist/deployments.d.ts +0 -117
- package/dist/deployments.d.ts.map +0 -1
- package/dist/deployments.js +0 -74
- package/dist/deployments.js.map +0 -1
- package/dist/errors.d.ts +0 -39
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -67
- package/dist/errors.js.map +0 -1
- package/dist/ev.d.ts +0 -123
- package/dist/ev.d.ts.map +0 -1
- package/dist/ev.js +0 -111
- package/dist/ev.js.map +0 -1
- package/dist/events.d.ts +0 -418
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js +0 -87
- package/dist/events.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/oracle.d.ts +0 -48
- package/dist/oracle.d.ts.map +0 -1
- package/dist/oracle.js +0 -77
- package/dist/oracle.js.map +0 -1
- package/dist/price.d.ts +0 -52
- package/dist/price.d.ts.map +0 -1
- package/dist/price.js +0 -78
- package/dist/price.js.map +0 -1
- package/dist/transaction.d.ts +0 -54
- package/dist/transaction.d.ts.map +0 -1
- package/dist/transaction.js +0 -105
- package/dist/transaction.js.map +0 -1
- package/dist/types.d.ts +0 -162
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -23
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -58
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -110
- package/dist/utils.js.map +0 -1
package/dist/utils.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateAddress = validateAddress;
|
|
4
|
-
exports.validateAmount = validateAmount;
|
|
5
|
-
exports.validateSquares = validateSquares;
|
|
6
|
-
exports.validateArrayLengths = validateArrayLengths;
|
|
7
|
-
exports.validateBps = validateBps;
|
|
8
|
-
exports.validateBpsSum = validateBpsSum;
|
|
9
|
-
exports.waitForTransactionReceipt = waitForTransactionReceipt;
|
|
10
|
-
const viem_1 = require("viem");
|
|
11
|
-
const errors_1 = require("./errors");
|
|
12
|
-
/**
|
|
13
|
-
* Validate and normalize an Ethereum address
|
|
14
|
-
* @param address Address to validate
|
|
15
|
-
* @param fieldName Field name for error message
|
|
16
|
-
* @returns Checksummed address
|
|
17
|
-
* @throws ValidationError if address is invalid
|
|
18
|
-
*/
|
|
19
|
-
function validateAddress(address, fieldName = 'address') {
|
|
20
|
-
if (!(0, viem_1.isAddress)(address)) {
|
|
21
|
-
throw new errors_1.ValidationError(`Invalid ${fieldName}: ${address}`, fieldName);
|
|
22
|
-
}
|
|
23
|
-
return (0, viem_1.getAddress)(address);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Validate that an amount is positive
|
|
27
|
-
* @param amount Amount to validate
|
|
28
|
-
* @param fieldName Field name for error message
|
|
29
|
-
* @throws ValidationError if amount is invalid
|
|
30
|
-
*/
|
|
31
|
-
function validateAmount(amount, fieldName = 'amount') {
|
|
32
|
-
if (amount < 0n) {
|
|
33
|
-
throw new errors_1.ValidationError(`${fieldName} must be non-negative`, fieldName);
|
|
34
|
-
}
|
|
35
|
-
if (amount === 0n) {
|
|
36
|
-
throw new errors_1.ValidationError(`${fieldName} must be greater than zero`, fieldName);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Validate square indices are within valid range
|
|
41
|
-
* @param squares Array of square indices
|
|
42
|
-
* @param gridSize Grid size (default 25)
|
|
43
|
-
* @throws ValidationError if squares are invalid
|
|
44
|
-
*/
|
|
45
|
-
function validateSquares(squares, gridSize = 25) {
|
|
46
|
-
if (squares.length === 0) {
|
|
47
|
-
throw new errors_1.ValidationError('At least one square must be provided', 'squares');
|
|
48
|
-
}
|
|
49
|
-
for (const square of squares) {
|
|
50
|
-
if (!Number.isInteger(square) || square < 0 || square >= gridSize) {
|
|
51
|
-
throw new errors_1.ValidationError(`Invalid square index: ${square}. Must be between 0 and ${gridSize - 1}`, 'squares');
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Validate that arrays have matching lengths
|
|
57
|
-
* @param arrays Arrays to validate
|
|
58
|
-
* @param fieldNames Field names for error message
|
|
59
|
-
* @throws ValidationError if arrays don't match
|
|
60
|
-
*/
|
|
61
|
-
function validateArrayLengths(arrays, fieldNames) {
|
|
62
|
-
if (arrays.length < 2) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const firstLength = arrays[0]?.length ?? 0;
|
|
66
|
-
for (let i = 1; i < arrays.length; i++) {
|
|
67
|
-
const currentArray = arrays[i];
|
|
68
|
-
const currentFieldName = fieldNames[i];
|
|
69
|
-
if (!currentArray || currentArray.length !== firstLength) {
|
|
70
|
-
throw new errors_1.ValidationError(`Array length mismatch: ${fieldNames[0]} has ${firstLength} items, but ${currentFieldName ?? `array ${i}`} has ${currentArray?.length ?? 0} items`, currentFieldName);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Validate basis points (0-10000)
|
|
76
|
-
* @param bps Basis points value
|
|
77
|
-
* @param fieldName Field name for error message
|
|
78
|
-
* @throws ValidationError if bps is invalid
|
|
79
|
-
*/
|
|
80
|
-
function validateBps(bps, fieldName = 'bps') {
|
|
81
|
-
if (!Number.isInteger(bps) || bps < 0 || bps > 10000) {
|
|
82
|
-
throw new errors_1.ValidationError(`${fieldName} must be an integer between 0 and 10000 (got ${bps})`, fieldName);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Validate that basis points array sums to 10000
|
|
87
|
-
* @param bpsArray Array of basis points
|
|
88
|
-
* @param fieldName Field name for error message
|
|
89
|
-
* @throws ValidationError if bps don't sum to 10000
|
|
90
|
-
*/
|
|
91
|
-
function validateBpsSum(bpsArray, fieldName = 'bpsAlloc') {
|
|
92
|
-
const sum = bpsArray.reduce((acc, bps) => acc + bps, 0);
|
|
93
|
-
if (sum !== 10000) {
|
|
94
|
-
throw new errors_1.ValidationError(`${fieldName} must sum to 10000 (got ${sum})`, fieldName);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Wait for transaction receipt with timeout
|
|
99
|
-
* @param publicClient Public client
|
|
100
|
-
* @param hash Transaction hash
|
|
101
|
-
* @param timeout Timeout in milliseconds (default 120000 = 2 minutes)
|
|
102
|
-
* @returns Transaction receipt
|
|
103
|
-
*/
|
|
104
|
-
async function waitForTransactionReceipt(publicClient, hash, timeout = 120000) {
|
|
105
|
-
if (!publicClient.waitForTransactionReceipt) {
|
|
106
|
-
throw new Error('Public client does not support waitForTransactionReceipt');
|
|
107
|
-
}
|
|
108
|
-
return await publicClient.waitForTransactionReceipt({ hash, timeout });
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAUA,0CAKC;AAQD,wCAOC;AAQD,0CAaC;AAQD,oDAgBC;AAQD,kCAOC;AAQD,wCAQC;AASD,8DASC;AA5HD,+BAAsD;AACtD,qCAA2C;AAE3C;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,OAAe,EAAE,YAAoB,SAAS;IAC5E,IAAI,CAAC,IAAA,gBAAS,EAAC,OAAO,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,wBAAe,CAAC,WAAW,SAAS,KAAK,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,IAAA,iBAAU,EAAC,OAAO,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,MAAc,EAAE,YAAoB,QAAQ;IACzE,IAAI,MAAM,GAAG,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,wBAAe,CAAC,GAA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