@haneullabs/haneul 2.4.0 → 2.5.1
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.d.mts +6 -6
- 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/name_service.client.d.mts +4 -4
- package/dist/grpc/proto/haneul/rpc/v2/signature_verification_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/Transaction.d.mts +6 -6
- package/dist/transactions/data/internal.d.mts +109 -109
- package/dist/transactions/data/v1.d.mts +220 -220
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.d.mts.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/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/bcs.d.mts.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/version.ts +1 -1
- package/src/zklogin/publickey.ts +9 -9
|
@@ -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/version.ts
CHANGED
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
|
|