@haneullabs/haneul 2.4.0 → 2.5.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.
- package/dist/bcs/bcs.mjs +1 -1
- package/dist/bcs/bcs.mjs.map +1 -1
- package/dist/bcs/index.d.mts +4 -4
- package/dist/client/core-resolver.mjs +2 -2
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/client/core.mjs +1 -1
- package/dist/client/core.mjs.map +1 -1
- package/dist/cryptography/keypair.d.mts +1 -1
- package/dist/cryptography/keypair.mjs +3 -3
- package/dist/cryptography/keypair.mjs.map +1 -1
- package/dist/cryptography/publickey.d.mts +1 -1
- package/dist/cryptography/publickey.mjs +2 -2
- package/dist/cryptography/publickey.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/grpc/proto/haneul/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/haneul/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/haneul/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/haneul/rpc/v2/subscription_service.client.d.mts +4 -4
- package/dist/grpc/proto/haneul/rpc/v2/system_state.d.mts +2 -2
- package/dist/grpc/proto/haneul/rpc/v2/system_state.mjs +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/system_state.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/jsonRpc/client.d.mts +5 -5
- package/dist/jsonRpc/client.d.mts.map +1 -1
- package/dist/jsonRpc/client.mjs +56 -56
- package/dist/jsonRpc/client.mjs.map +1 -1
- package/dist/jsonRpc/core.mjs +6 -6
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/jsonRpc/index.d.mts +4 -4
- package/dist/jsonRpc/index.mjs +2 -2
- package/dist/jsonRpc/types/generated.d.mts +14 -14
- package/dist/jsonRpc/types/generated.d.mts.map +1 -1
- package/dist/jsonRpc/types/index.d.mts +2 -2
- package/dist/jsonRpc/types/params.d.mts +8 -8
- package/dist/jsonRpc/types/params.d.mts.map +1 -1
- package/dist/multisig/publickey.d.mts +1 -1
- package/dist/multisig/publickey.mjs +1 -1
- package/dist/multisig/publickey.mjs.map +1 -1
- package/dist/multisig/signer.mjs +2 -2
- package/dist/multisig/signer.mjs.map +1 -1
- package/dist/transactions/Commands.mjs +3 -3
- package/dist/transactions/Commands.mjs.map +1 -1
- package/dist/transactions/executor/caching.mjs +1 -1
- package/dist/transactions/executor/caching.mjs.map +1 -1
- package/dist/transactions/executor/parallel.mjs +3 -3
- package/dist/transactions/executor/parallel.mjs.map +1 -1
- package/dist/transactions/executor/serial.mjs +1 -1
- package/dist/transactions/executor/serial.mjs.map +1 -1
- package/dist/utils/haneul-types.d.mts +2 -2
- package/dist/utils/haneul-types.d.mts.map +1 -1
- package/dist/utils/haneul-types.mjs +2 -2
- package/dist/utils/haneul-types.mjs.map +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.mjs +2 -2
- package/dist/verify/verify.mjs +1 -1
- package/dist/verify/verify.mjs.map +1 -1
- package/dist/zklogin/publickey.d.mts +1 -1
- package/dist/zklogin/publickey.d.mts.map +1 -1
- package/dist/zklogin/publickey.mjs +9 -9
- package/dist/zklogin/publickey.mjs.map +1 -1
- package/package.json +199 -199
- package/src/bcs/bcs.ts +1 -1
- package/src/client/core-resolver.ts +2 -2
- package/src/client/core.ts +1 -1
- package/src/cryptography/keypair.ts +3 -3
- package/src/cryptography/publickey.ts +2 -2
- package/src/grpc/proto/haneul/rpc/v2/system_state.ts +3 -3
- package/src/jsonRpc/client.ts +57 -57
- package/src/jsonRpc/core.ts +7 -7
- package/src/jsonRpc/index.ts +1 -1
- package/src/jsonRpc/types/generated.ts +13 -13
- package/src/jsonRpc/types/params.ts +7 -7
- package/src/multisig/publickey.ts +1 -1
- package/src/multisig/signer.ts +2 -2
- package/src/transactions/Commands.ts +3 -3
- package/src/transactions/executor/caching.ts +1 -1
- package/src/transactions/executor/parallel.ts +3 -3
- package/src/transactions/executor/serial.ts +1 -1
- package/src/utils/haneul-types.ts +1 -1
- package/src/utils/index.ts +1 -1
- package/src/verify/verify.ts +1 -1
- package/src/zklogin/publickey.ts +9 -9
|
@@ -298,7 +298,7 @@ export interface GetDynamicFieldsParams {
|
|
|
298
298
|
signal?: AbortSignal;
|
|
299
299
|
}
|
|
300
300
|
/** Return the latest HANEUL system state object on-chain. */
|
|
301
|
-
export interface
|
|
301
|
+
export interface GetLatestHaneulSystemStateParams {
|
|
302
302
|
signal?: AbortSignal;
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
@@ -329,7 +329,7 @@ export interface GetStakesParams {
|
|
|
329
329
|
}
|
|
330
330
|
/** Return one or more [DelegatedStake]. If a Stake was withdrawn its status will be Unstaked. */
|
|
331
331
|
export interface GetStakesByIdsParams {
|
|
332
|
-
|
|
332
|
+
stakedHaneulIds: string[];
|
|
333
333
|
signal?: AbortSignal;
|
|
334
334
|
}
|
|
335
335
|
/** Return total supply for a coin */
|
|
@@ -503,7 +503,7 @@ export interface UnsafePayParams {
|
|
|
503
503
|
* use this first coin as gas coin object. 3. the balance of the first input coin after tx is
|
|
504
504
|
* sum(input_coins) - actual_gas_cost. 4. all other input coins other than the first are deleted.
|
|
505
505
|
*/
|
|
506
|
-
export interface
|
|
506
|
+
export interface UnsafePayAllHaneulParams {
|
|
507
507
|
/** the transaction signer's Haneul address */
|
|
508
508
|
signer: string;
|
|
509
509
|
/** the Haneul coins to be used in this transaction, including the coin for gas payment. */
|
|
@@ -523,7 +523,7 @@ export interface UnsafePayAllSuiParams {
|
|
|
523
523
|
* coin after tx is sum(input_coins) - sum(amounts) - actual_gas_cost 4. all other input coints other
|
|
524
524
|
* than the first one are deleted.
|
|
525
525
|
*/
|
|
526
|
-
export interface
|
|
526
|
+
export interface UnsafePayHaneulParams {
|
|
527
527
|
/** the transaction signer's Haneul address */
|
|
528
528
|
signer: string;
|
|
529
529
|
/** the Haneul coins to be used in this transaction, including the coin for gas payment. */
|
|
@@ -576,8 +576,8 @@ export interface UnsafeRequestAddStakeParams {
|
|
|
576
576
|
export interface UnsafeRequestWithdrawStakeParams {
|
|
577
577
|
/** the transaction signer's Haneul address */
|
|
578
578
|
signer: string;
|
|
579
|
-
/**
|
|
580
|
-
|
|
579
|
+
/** StakedHaneul object ID */
|
|
580
|
+
stakedHaneul: string;
|
|
581
581
|
/**
|
|
582
582
|
* gas object to be used in this transaction, node will pick one from the signer's possession if not
|
|
583
583
|
* provided
|
|
@@ -645,7 +645,7 @@ export interface UnsafeTransferObjectParams {
|
|
|
645
645
|
* Create an unsigned transaction to send HANEUL coin object to a Haneul address. The HANEUL object is also used
|
|
646
646
|
* as the gas object.
|
|
647
647
|
*/
|
|
648
|
-
export interface
|
|
648
|
+
export interface UnsafeTransferHaneulParams {
|
|
649
649
|
/** the transaction signer's Haneul address */
|
|
650
650
|
signer: string;
|
|
651
651
|
/** the Haneul coin object to be used in this transaction */
|
|
@@ -187,7 +187,7 @@ export class MultiSigPublicKey extends PublicKey {
|
|
|
187
187
|
/**
|
|
188
188
|
* Return the Haneul address associated with this MultiSig public key
|
|
189
189
|
*/
|
|
190
|
-
override
|
|
190
|
+
override toHaneulAddress(): string {
|
|
191
191
|
// max length = 1 flag byte + (max pk size + max weight size (u8)) * max signer size + 2 threshold bytes (u16)
|
|
192
192
|
const maxLength = 1 + (64 + 1) * MAX_SIGNER_IN_MULTISIG + 2;
|
|
193
193
|
const tmp = new Uint8Array(maxLength);
|
package/src/multisig/signer.ts
CHANGED
|
@@ -20,11 +20,11 @@ export class MultiSigSigner extends Signer {
|
|
|
20
20
|
|
|
21
21
|
const weights = pubkey.getPublicKeys().map(({ weight, publicKey }) => ({
|
|
22
22
|
weight,
|
|
23
|
-
address: publicKey.
|
|
23
|
+
address: publicKey.toHaneulAddress(),
|
|
24
24
|
}));
|
|
25
25
|
|
|
26
26
|
for (const signer of signers) {
|
|
27
|
-
const address = signer.
|
|
27
|
+
const address = signer.toHaneulAddress();
|
|
28
28
|
if (uniqueKeys.has(address)) {
|
|
29
29
|
throw new Error(`Can't create MultiSigSigner with duplicate signers`);
|
|
30
30
|
}
|
|
@@ -5,7 +5,7 @@ import { toBase64 } from '@haneullabs/bcs';
|
|
|
5
5
|
import type { InferInput } from 'valibot';
|
|
6
6
|
import { parse } from 'valibot';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { normalizeHaneulObjectId } from '../utils/haneul-types.js';
|
|
9
9
|
import type { Argument, CallArg, Command } from './data/internal.js';
|
|
10
10
|
import { ArgumentSchema } from './data/internal.js';
|
|
11
11
|
import type { AsyncTransactionThunk, Transaction } from './Transaction.js';
|
|
@@ -111,7 +111,7 @@ export const TransactionCommands = {
|
|
|
111
111
|
modules: modules.map((module) =>
|
|
112
112
|
typeof module === 'string' ? module : toBase64(new Uint8Array(module)),
|
|
113
113
|
),
|
|
114
|
-
dependencies: dependencies.map((dep) =>
|
|
114
|
+
dependencies: dependencies.map((dep) => normalizeHaneulObjectId(dep)),
|
|
115
115
|
},
|
|
116
116
|
};
|
|
117
117
|
},
|
|
@@ -132,7 +132,7 @@ export const TransactionCommands = {
|
|
|
132
132
|
modules: modules.map((module) =>
|
|
133
133
|
typeof module === 'string' ? module : toBase64(new Uint8Array(module)),
|
|
134
134
|
),
|
|
135
|
-
dependencies: dependencies.map((dep) =>
|
|
135
|
+
dependencies: dependencies.map((dep) => normalizeHaneulObjectId(dep)),
|
|
136
136
|
package: packageId,
|
|
137
137
|
ticket: parse(ArgumentSchema, ticket),
|
|
138
138
|
},
|
|
@@ -95,7 +95,7 @@ export class CachingTransactionExecutor {
|
|
|
95
95
|
signer: Signer;
|
|
96
96
|
include?: Include;
|
|
97
97
|
}): Promise<HaneulClientTypes.TransactionResult<Include & { effects: true }>> {
|
|
98
|
-
transaction.setSenderIfNotSet(signer.
|
|
98
|
+
transaction.setSenderIfNotSet(signer.toHaneulAddress());
|
|
99
99
|
const bytes = await this.buildTransaction({ transaction });
|
|
100
100
|
const { signature } = await signer.signTransaction(bytes);
|
|
101
101
|
return this.executeTransaction({
|
|
@@ -206,7 +206,7 @@ export class ParallelTransactionExecutor {
|
|
|
206
206
|
): Promise<HaneulClientTypes.TransactionResult<Include & { effects: true }>> {
|
|
207
207
|
let gasCoin: CoinWithBalance | null = null;
|
|
208
208
|
try {
|
|
209
|
-
transaction.setSenderIfNotSet(this.#signer.
|
|
209
|
+
transaction.setSenderIfNotSet(this.#signer.toHaneulAddress());
|
|
210
210
|
|
|
211
211
|
await this.#buildQueue.runTask(async () => {
|
|
212
212
|
const data = transaction.getData();
|
|
@@ -259,7 +259,7 @@ export class ParallelTransactionExecutor {
|
|
|
259
259
|
const coin = gasCoin as CoinWithBalance;
|
|
260
260
|
const gasOwner = gasObject.outputOwner?.AddressOwner ?? gasObject.outputOwner?.ObjectOwner;
|
|
261
261
|
|
|
262
|
-
if (gasOwner === this.#signer.
|
|
262
|
+
if (gasOwner === this.#signer.toHaneulAddress()) {
|
|
263
263
|
const totalUsed =
|
|
264
264
|
BigInt(gasUsed.computationCost) +
|
|
265
265
|
BigInt(gasUsed.storageCost) +
|
|
@@ -431,7 +431,7 @@ export class ParallelTransactionExecutor {
|
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
const txb = new Transaction();
|
|
434
|
-
const address = this.#signer.
|
|
434
|
+
const address = this.#signer.toHaneulAddress();
|
|
435
435
|
txb.setSender(address);
|
|
436
436
|
|
|
437
437
|
if (this.#sourceCoins) {
|
|
@@ -102,7 +102,7 @@ export class SerialTransactionExecutor {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
copy.setGasBudgetIfNotSet(this.#defaultGasBudget);
|
|
105
|
-
copy.setSenderIfNotSet(this.#signer.
|
|
105
|
+
copy.setSenderIfNotSet(this.#signer.toHaneulAddress());
|
|
106
106
|
|
|
107
107
|
return this.#cache.buildTransaction({ transaction: copy });
|
|
108
108
|
};
|
|
@@ -163,7 +163,7 @@ export function normalizeHaneulAddress(value: string, forceAdd0x: boolean = fals
|
|
|
163
163
|
return `0x${address.padStart(HANEUL_ADDRESS_LENGTH * 2, '0')}`;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
export function
|
|
166
|
+
export function normalizeHaneulObjectId(value: string, forceAdd0x: boolean = false): string {
|
|
167
167
|
return normalizeHaneulAddress(value, forceAdd0x);
|
|
168
168
|
}
|
|
169
169
|
|
package/src/utils/index.ts
CHANGED
package/src/verify/verify.ts
CHANGED
|
@@ -129,7 +129,7 @@ export function publicKeyFromRawBytes(
|
|
|
129
129
|
throw new Error(`Unsupported signature scheme ${signatureScheme}`);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
if (options.address && publicKey.
|
|
132
|
+
if (options.address && publicKey.toHaneulAddress() !== options.address) {
|
|
133
133
|
throw new Error(`Public key bytes do not match the provided address`);
|
|
134
134
|
}
|
|
135
135
|
|
package/src/zklogin/publickey.ts
CHANGED
|
@@ -69,7 +69,7 @@ export class ZkLoginPublicIdentifier extends PublicKey {
|
|
|
69
69
|
client,
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
if (publicKey.
|
|
72
|
+
if (publicKey.toHaneulAddress() !== address) {
|
|
73
73
|
publicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, true), {
|
|
74
74
|
client,
|
|
75
75
|
});
|
|
@@ -80,7 +80,7 @@ export class ZkLoginPublicIdentifier extends PublicKey {
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
if (address && publicKey.
|
|
83
|
+
if (address && publicKey.toHaneulAddress() !== address) {
|
|
84
84
|
throw new Error('Public key bytes do not match the provided address');
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -95,7 +95,7 @@ export class ZkLoginPublicIdentifier extends PublicKey {
|
|
|
95
95
|
legacyAddress: true,
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
if (legacyPublicKey.
|
|
98
|
+
if (legacyPublicKey.toHaneulAddress() === address) {
|
|
99
99
|
return legacyPublicKey;
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -103,7 +103,7 @@ export class ZkLoginPublicIdentifier extends PublicKey {
|
|
|
103
103
|
legacyAddress: false,
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
-
if (publicKey.
|
|
106
|
+
if (publicKey.toHaneulAddress() !== address) {
|
|
107
107
|
throw new Error('Proof does not match address');
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -117,12 +117,12 @@ export class ZkLoginPublicIdentifier extends PublicKey {
|
|
|
117
117
|
return super.equals(publicKey);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
override
|
|
120
|
+
override toHaneulAddress(): string {
|
|
121
121
|
if (this.#legacyAddress) {
|
|
122
122
|
return this.#toLegacyAddress();
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
return super.
|
|
125
|
+
return super.toHaneulAddress();
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
#toLegacyAddress() {
|
|
@@ -161,7 +161,7 @@ export class ZkLoginPublicIdentifier extends PublicKey {
|
|
|
161
161
|
*/
|
|
162
162
|
verifyPersonalMessage(message: Uint8Array, signature: Uint8Array | string): Promise<boolean> {
|
|
163
163
|
const parsedSignature = parseSerializedZkLoginSignature(signature);
|
|
164
|
-
const address = new ZkLoginPublicIdentifier(parsedSignature.publicKey).
|
|
164
|
+
const address = new ZkLoginPublicIdentifier(parsedSignature.publicKey).toHaneulAddress();
|
|
165
165
|
|
|
166
166
|
return graphqlVerifyZkLoginSignature({
|
|
167
167
|
address: address,
|
|
@@ -177,7 +177,7 @@ export class ZkLoginPublicIdentifier extends PublicKey {
|
|
|
177
177
|
*/
|
|
178
178
|
verifyTransaction(transaction: Uint8Array, signature: Uint8Array | string): Promise<boolean> {
|
|
179
179
|
const parsedSignature = parseSerializedZkLoginSignature(signature);
|
|
180
|
-
const address = new ZkLoginPublicIdentifier(parsedSignature.publicKey).
|
|
180
|
+
const address = new ZkLoginPublicIdentifier(parsedSignature.publicKey).toHaneulAddress();
|
|
181
181
|
return graphqlVerifyZkLoginSignature({
|
|
182
182
|
address: address,
|
|
183
183
|
bytes: toBase64(transaction),
|
|
@@ -191,7 +191,7 @@ export class ZkLoginPublicIdentifier extends PublicKey {
|
|
|
191
191
|
* Verifies that the public key is associated with the provided address
|
|
192
192
|
*/
|
|
193
193
|
override verifyAddress(address: string): boolean {
|
|
194
|
-
return address === super.
|
|
194
|
+
return address === super.toHaneulAddress() || address === this.#toLegacyAddress();
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
|