genlayer-js 0.18.2 → 0.18.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/CHANGELOG.md +7 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/contracts/actions.ts +2 -2
- package/tests/client.test.ts +26 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## 0.18.3 (2025-11-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* default to zero address for read operations when account not provided ([#121](https://github.com/genlayerlabs/genlayer-js/issues/121)) ([6a1b47a](https://github.com/genlayerlabs/genlayer-js/commit/6a1b47aeafaeb807d5219abbb88e10041c03030e))
|
|
9
|
+
|
|
3
10
|
## 0.18.2 (2025-09-18)
|
|
4
11
|
|
|
5
12
|
|
package/dist/index.cjs
CHANGED
|
@@ -555,7 +555,7 @@ var contractActions = (client, publicClient) => {
|
|
|
555
555
|
} = args;
|
|
556
556
|
const encodedData = [encode(makeCalldataObject(functionName, callArgs, kwargs)), leaderOnly];
|
|
557
557
|
const serializedData = serialize(encodedData);
|
|
558
|
-
const senderAddress = _nullishCoalesce(_optionalChain([account, 'optionalAccess', _5 => _5.address]), () => ( _optionalChain([client, 'access', _6 => _6.account, 'optionalAccess', _7 => _7.address])));
|
|
558
|
+
const senderAddress = _nullishCoalesce(_nullishCoalesce(_optionalChain([account, 'optionalAccess', _5 => _5.address]), () => ( _optionalChain([client, 'access', _6 => _6.account, 'optionalAccess', _7 => _7.address]))), () => ( _viem.zeroAddress));
|
|
559
559
|
const requestParams = {
|
|
560
560
|
type: "read",
|
|
561
561
|
to: address,
|
|
@@ -590,7 +590,7 @@ var contractActions = (client, publicClient) => {
|
|
|
590
590
|
} = args;
|
|
591
591
|
const encodedData = [encode(makeCalldataObject(functionName, callArgs, kwargs)), leaderOnly];
|
|
592
592
|
const serializedData = serialize(encodedData);
|
|
593
|
-
const senderAddress = _nullishCoalesce(_optionalChain([account, 'optionalAccess', _8 => _8.address]), () => ( _optionalChain([client, 'access', _9 => _9.account, 'optionalAccess', _10 => _10.address])));
|
|
593
|
+
const senderAddress = _nullishCoalesce(_nullishCoalesce(_optionalChain([account, 'optionalAccess', _8 => _8.address]), () => ( _optionalChain([client, 'access', _9 => _9.account, 'optionalAccess', _10 => _10.address]))), () => ( _viem.zeroAddress));
|
|
594
594
|
const requestParams = {
|
|
595
595
|
type: "write",
|
|
596
596
|
to: address,
|
package/dist/index.js
CHANGED
|
@@ -555,7 +555,7 @@ var contractActions = (client, publicClient) => {
|
|
|
555
555
|
} = args;
|
|
556
556
|
const encodedData = [encode(makeCalldataObject(functionName, callArgs, kwargs)), leaderOnly];
|
|
557
557
|
const serializedData = serialize(encodedData);
|
|
558
|
-
const senderAddress = account?.address ?? client.account?.address;
|
|
558
|
+
const senderAddress = account?.address ?? client.account?.address ?? zeroAddress;
|
|
559
559
|
const requestParams = {
|
|
560
560
|
type: "read",
|
|
561
561
|
to: address,
|
|
@@ -590,7 +590,7 @@ var contractActions = (client, publicClient) => {
|
|
|
590
590
|
} = args;
|
|
591
591
|
const encodedData = [encode(makeCalldataObject(functionName, callArgs, kwargs)), leaderOnly];
|
|
592
592
|
const serializedData = serialize(encodedData);
|
|
593
|
-
const senderAddress = account?.address ?? client.account?.address;
|
|
593
|
+
const senderAddress = account?.address ?? client.account?.address ?? zeroAddress;
|
|
594
594
|
const requestParams = {
|
|
595
595
|
type: "write",
|
|
596
596
|
to: address,
|
package/package.json
CHANGED
package/src/contracts/actions.ts
CHANGED
|
@@ -71,7 +71,7 @@ export const contractActions = (client: GenLayerClient<GenLayerChain>, publicCli
|
|
|
71
71
|
const encodedData = [calldata.encode(calldata.makeCalldataObject(functionName, callArgs, kwargs)), leaderOnly];
|
|
72
72
|
const serializedData = serialize(encodedData);
|
|
73
73
|
|
|
74
|
-
const senderAddress = account?.address ?? client.account?.address;
|
|
74
|
+
const senderAddress = account?.address ?? client.account?.address ?? zeroAddress;
|
|
75
75
|
|
|
76
76
|
const requestParams = {
|
|
77
77
|
type: "read",
|
|
@@ -120,7 +120,7 @@ export const contractActions = (client: GenLayerClient<GenLayerChain>, publicCli
|
|
|
120
120
|
const encodedData = [calldata.encode(calldata.makeCalldataObject(functionName, callArgs, kwargs)), leaderOnly];
|
|
121
121
|
const serializedData = serialize(encodedData);
|
|
122
122
|
|
|
123
|
-
const senderAddress = account?.address ?? client.account?.address;
|
|
123
|
+
const senderAddress = account?.address ?? client.account?.address ?? zeroAddress;
|
|
124
124
|
|
|
125
125
|
const requestParams = {
|
|
126
126
|
type: "write",
|
package/tests/client.test.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {Address} from "../src/types/accounts";
|
|
|
5
5
|
import {createAccount, generatePrivateKey} from "../src/accounts/account";
|
|
6
6
|
import {vi} from "vitest";
|
|
7
7
|
import {TransactionHashVariant} from "../src/types/transactions";
|
|
8
|
+
import {zeroAddress} from "viem";
|
|
8
9
|
|
|
9
10
|
// Setup fetch mock
|
|
10
11
|
const mockFetch = vi.fn();
|
|
@@ -168,4 +169,29 @@ describe("Client Overrides", () => {
|
|
|
168
169
|
},
|
|
169
170
|
]);
|
|
170
171
|
});
|
|
172
|
+
|
|
173
|
+
it("should use zero address when no account is provided anywhere", async () => {
|
|
174
|
+
const client = createClient({
|
|
175
|
+
chain: localnet,
|
|
176
|
+
// No account provided on client
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
const contractAddress = "0x1234567890123456789012345678901234567890";
|
|
180
|
+
await client.readContract({
|
|
181
|
+
// No account override either
|
|
182
|
+
address: contractAddress as Address,
|
|
183
|
+
functionName: "testFunction",
|
|
184
|
+
args: ["arg1", "arg2"],
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
expect(lastGenCallParams).toEqual([
|
|
188
|
+
{
|
|
189
|
+
type: "read",
|
|
190
|
+
to: contractAddress,
|
|
191
|
+
from: zeroAddress, // Should default to zero address
|
|
192
|
+
data: expect.any(String),
|
|
193
|
+
transaction_hash_variant: TransactionHashVariant.LATEST_NONFINAL,
|
|
194
|
+
},
|
|
195
|
+
]);
|
|
196
|
+
});
|
|
171
197
|
});
|