@fizzyflow/endless-vector 0.0.2 → 0.0.3
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/EndlessVector.js +11 -4
- package/package.json +1 -1
package/EndlessVector.js
CHANGED
|
@@ -105,10 +105,17 @@ export default class EndlessVector {
|
|
|
105
105
|
static async create(params) {
|
|
106
106
|
const { suiClient, packageId, signAndExecuteTransaction, items, gasCoin, options = {} } = params;
|
|
107
107
|
|
|
108
|
+
let normalizedPackageId = packageId;
|
|
109
|
+
if (normalizedPackageId == 'mainnet' || (!normalizedPackageId && suiClient?.network == 'mainnet')) {
|
|
110
|
+
normalizedPackageId = ids['mainnet'].packageId;
|
|
111
|
+
} else if (normalizedPackageId == 'testnet' || (!normalizedPackageId && suiClient?.network == 'testnet')) {
|
|
112
|
+
normalizedPackageId = ids['testnet'].packageId;
|
|
113
|
+
}
|
|
114
|
+
|
|
108
115
|
if (!suiClient) {
|
|
109
116
|
throw new Error('suiClient is required');
|
|
110
117
|
}
|
|
111
|
-
if (!
|
|
118
|
+
if (!normalizedPackageId) {
|
|
112
119
|
throw new Error('packageId is required');
|
|
113
120
|
}
|
|
114
121
|
if (!signAndExecuteTransaction) {
|
|
@@ -124,12 +131,12 @@ export default class EndlessVector {
|
|
|
124
131
|
|
|
125
132
|
if (items && Array.isArray(items) && items.length) {
|
|
126
133
|
tx.moveCall({
|
|
127
|
-
target: `${
|
|
134
|
+
target: `${normalizedPackageId}::endless_vector::empty_entry_and_push`,
|
|
128
135
|
arguments: [tx.pure(bcs.vector(bcs.vector(bcs.u8())).serialize(items))],
|
|
129
136
|
});
|
|
130
137
|
} else {
|
|
131
138
|
tx.moveCall({
|
|
132
|
-
target: `${
|
|
139
|
+
target: `${normalizedPackageId}::endless_vector::empty_entry`,
|
|
133
140
|
arguments: [],
|
|
134
141
|
});
|
|
135
142
|
}
|
|
@@ -168,7 +175,7 @@ export default class EndlessVector {
|
|
|
168
175
|
return new EndlessVector({
|
|
169
176
|
suiClient,
|
|
170
177
|
id: createdVector.objectId,
|
|
171
|
-
packageId,
|
|
178
|
+
packageId: normalizedPackageId,
|
|
172
179
|
signAndExecuteTransaction,
|
|
173
180
|
});
|
|
174
181
|
}
|