@pushchain/core 0.1.16 → 0.1.18
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 +11 -226
- package/package.json +1 -1
- package/src/lib/constants/abi/factoryV1.d.ts +15 -16
- package/src/lib/constants/abi/factoryV1.js +276 -193
- package/src/lib/constants/abi/factoryV1.js.map +1 -1
- package/src/lib/constants/abi/feeLocker.evm.d.ts +22 -22
- package/src/lib/constants/abi/feeLocker.evm.js +273 -229
- package/src/lib/constants/abi/feeLocker.evm.js.map +1 -1
- package/src/lib/constants/abi/index.d.ts +2 -2
- package/src/lib/constants/abi/index.js +5 -5
- package/src/lib/constants/abi/index.js.map +1 -1
- package/src/lib/constants/abi/{smartAccount.evm.d.ts → uea.evm.d.ts} +15 -22
- package/src/lib/constants/abi/{smartAccount.evm.js → uea.evm.js} +49 -59
- package/src/lib/constants/abi/uea.evm.js.map +1 -0
- package/src/lib/constants/abi/{smartAccount.svm.d.ts → uea.svm.d.ts} +15 -22
- package/src/lib/constants/abi/{smartAccount.svm.js → uea.svm.js} +49 -59
- package/src/lib/constants/abi/uea.svm.js.map +1 -0
- package/src/lib/constants/chain.js +7 -7
- package/src/lib/constants/chain.js.map +1 -1
- package/src/lib/generated/v1/tx.d.ts +44 -31
- package/src/lib/generated/v1/tx.js +120 -157
- package/src/lib/generated/v1/tx.js.map +1 -1
- package/src/lib/orchestrator/orchestrator.d.ts +28 -21
- package/src/lib/orchestrator/orchestrator.js +170 -218
- package/src/lib/orchestrator/orchestrator.js.map +1 -1
- package/src/lib/orchestrator/orchestrator.types.d.ts +1 -1
- package/src/lib/price-fetch/price-fetch.js +23 -13
- package/src/lib/price-fetch/price-fetch.js.map +1 -1
- package/src/lib/push-client/push-client.d.ts +10 -3
- package/src/lib/push-client/push-client.js +25 -6
- package/src/lib/push-client/push-client.js.map +1 -1
- package/src/lib/pushChain.d.ts +28 -17
- package/src/lib/pushChain.js +33 -15
- package/src/lib/pushChain.js.map +1 -1
- package/src/lib/universal/account/account.js +3 -11
- package/src/lib/universal/account/account.js.map +1 -1
- package/src/lib/universal/signer/signer.js +4 -3
- package/src/lib/universal/signer/signer.js.map +1 -1
- package/src/lib/constants/abi/smartAccount.evm.js.map +0 -1
- package/src/lib/constants/abi/smartAccount.svm.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,241 +1,26 @@
|
|
|
1
1
|
# Push Chain Core
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
or [Push.org](https://push.org) to learn more.
|
|
3
|
+
## Overview
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
- [Installation](#installation)
|
|
8
|
-
- [Import SDK](#import-sdk)
|
|
9
|
-
- [Initialize SDK](#initialize-sdk)
|
|
10
|
-
- [Read-only mode (without signer)](#read-only-mode-without-signer)
|
|
11
|
-
- [With signer](#with-signer)
|
|
12
|
-
- [UniversalSigner structure](#universalsigner-structure)
|
|
13
|
-
- [Example using `viem` to create a UniversalSigner](#example-using-viem-to-create-a-universalsigner)
|
|
14
|
-
- [Execute Cross-Chain Transaction](#execute-cross-chain-transaction)
|
|
15
|
-
- [Utilities](#utilities)
|
|
16
|
-
- [Converts CAIP-10 address to UniversalAccount](#converts-caip-10-address-to-universalaccount)
|
|
17
|
-
- [Converts UniversalAccount to CAIP-10 address](#converts-universalaccount-to-caip-10-address)
|
|
18
|
-
- [Convert viem account or walletClient to UniversalSigner](#convert-viem-account-or-walletclient-to-universalsigner)
|
|
19
|
-
- [Convert Solana keypair to UniversalSigner](#convert-solana-keypair-to-universalsigner)
|
|
5
|
+
Push Chain is a true universal L1 that is 100% EVM compatible. It allows developers to deploy once and make their apps instantly compatible with users from all other L1s (Ethereum, Solana, etc) with zero on-chain code change.
|
|
20
6
|
|
|
21
|
-
|
|
7
|
+
`@pushchain/core` provides core functionality to interact with the Push Chain. It enables developers to easily integrate universal messaging, transactions, and utilities into their applications.
|
|
22
8
|
|
|
23
|
-
##
|
|
9
|
+
## Documentation
|
|
24
10
|
|
|
25
|
-
|
|
11
|
+
For full documentation, API references, and guides, visit:
|
|
12
|
+
👉 [Push Chain Developer Docs](https://push.org/docs)
|
|
26
13
|
|
|
27
|
-
|
|
28
|
-
yarn add @pushchain/core
|
|
29
|
-
```
|
|
14
|
+
## Installation Guide
|
|
30
15
|
|
|
31
|
-
|
|
16
|
+
Install via npm:
|
|
32
17
|
|
|
33
18
|
```bash
|
|
34
19
|
npm install @pushchain/core
|
|
35
20
|
```
|
|
36
21
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Import SDK
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
import { PushChain } from '@pushchain/core';
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
### Initialize SDK
|
|
48
|
-
|
|
49
|
-
#### Read-only mode (without signer)
|
|
50
|
-
|
|
51
|
-
> 🟡 Coming soon
|
|
52
|
-
> You will be able to use the SDK in read-only mode for querying without attaching a signer.
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
#### With signer
|
|
57
|
-
|
|
58
|
-
To send cross-chain transactions or perform signature-based validations, you need to initialize the SDK with a `UniversalSigner`.
|
|
59
|
-
|
|
60
|
-
The `UniversalSigner` abstracts signing across different chains and VMs (EVM, Solana, etc.), allowing Push Chain to use a unified interface for signing messages and transactions on the **source chain**.
|
|
61
|
-
|
|
62
|
-
> 💡 You can use `PushChain.utils.signer` to wrap native EVM or Solana signers into a compatible `UniversalSigner`.
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
##### UniversalSigner structure
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
/**
|
|
70
|
-
* A chain-agnostic account representation.
|
|
71
|
-
* Used to represent a wallet address along with its chain context.
|
|
72
|
-
*/
|
|
73
|
-
export interface UniversalAccount {
|
|
74
|
-
/**
|
|
75
|
-
* Fully qualified chain (e.g., CHAIN.ETHEREUM_SEPOLIA, CHAIN.SOLANA_DEVNET)
|
|
76
|
-
*/
|
|
77
|
-
chain: CHAIN;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* The address on the respective chain (EVM: checksummed, Solana: base58, etc.)
|
|
81
|
-
*/
|
|
82
|
-
address: string;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* A signer capable of signing messages for a specific chain.
|
|
87
|
-
* Used to abstract away signing across multiple VM types.
|
|
88
|
-
*/
|
|
89
|
-
export interface UniversalSigner extends UniversalAccount {
|
|
90
|
-
/**
|
|
91
|
-
* Signs an arbitrary message as a Uint8Array.
|
|
92
|
-
* Use UTF-8 encoding for strings before signing.
|
|
93
|
-
*/
|
|
94
|
-
signMessage: (data: Uint8Array) => Promise<Uint8Array>;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Signs EIP-712 typed data.
|
|
98
|
-
* Optional. Only required for EVM signers.
|
|
99
|
-
*/
|
|
100
|
-
signTypedData?: ({
|
|
101
|
-
domain,
|
|
102
|
-
types,
|
|
103
|
-
primaryType,
|
|
104
|
-
message,
|
|
105
|
-
}: {
|
|
106
|
-
domain: TypedDataDomain;
|
|
107
|
-
types: TypedData;
|
|
108
|
-
primaryType: string;
|
|
109
|
-
message: Record<string, any>;
|
|
110
|
-
}) => Promise<Uint8Array>;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Signs and sends a transaction (unsigned transaction bytes).
|
|
114
|
-
* Used for direct on-chain sending when necessary.
|
|
115
|
-
*/
|
|
116
|
-
signAndSendTransaction: (unsignedTx: Uint8Array) => Promise<Uint8Array>;
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
##### Example using `viem` to create a UniversalSigner
|
|
123
|
-
|
|
124
|
-
```ts
|
|
125
|
-
import { hexToBytes } from 'viem';
|
|
126
|
-
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
127
|
-
import { CHAIN } from '@pushchain/core/constants/enums';
|
|
128
|
-
import { PushChain } from '@pushchain/core';
|
|
129
|
-
|
|
130
|
-
const privateKey = generatePrivateKey();
|
|
131
|
-
const account = privateKeyToAccount(privateKey);
|
|
132
|
-
|
|
133
|
-
const signer: UniversalSigner = PushChain.utils.signer.toUniversalFromViem(
|
|
134
|
-
account,
|
|
135
|
-
CHAIN.ETHEREUM_SEPOLIA
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
const pushChain = await PushChain.initialize(signer);
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
**Parameters:**
|
|
142
|
-
|
|
143
|
-
| Param | Type | Default | Description |
|
|
144
|
-
| ----------------- | ----------------- | --------- | ------------------------------------------------------------------------------ |
|
|
145
|
-
| `universalSigner` | `UniversalSigner` | `null` | Required for sending transactions or verifying signatures on the source chain. |
|
|
146
|
-
| `options.network` | `PUSH_NETWORK` | `testnet` | Push Chain environment. Can be `testnet`, or `mainnet`. |
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
### Execute Cross-Chain Transaction
|
|
151
|
-
|
|
152
|
-
```ts
|
|
153
|
-
pushchain.execute({
|
|
154
|
-
// Target to execute on Push Chain - Can be EOA or smart contract address
|
|
155
|
-
target: '0x2FE70447492307108Bdc7Ff6BaB33Ff37Dacc479',
|
|
156
|
-
// Amount to send to the target in npush
|
|
157
|
-
value: BigInt(0),
|
|
158
|
-
// Data to send to the target - contract function call data
|
|
159
|
-
data: '0x2ba2ed980000000000000000000000000000000000000000000000000000000000000312',
|
|
160
|
-
// Gas limit for the transaction on Push Chain
|
|
161
|
-
gasLimit: BigInt(50000000000000000),
|
|
162
|
-
// Max fee per gas on Push Chain
|
|
163
|
-
maxFeePerGas: BigInt(50000000000000000),
|
|
164
|
-
// Max priority fee per gas on Push Chain
|
|
165
|
-
maxPriorityFeePerGas: BigInt(200000000),
|
|
166
|
-
// Deadline for the transaction to be executed on Push Chain
|
|
167
|
-
deadline: BigInt(9999999999),
|
|
168
|
-
});
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
**Parameters:**
|
|
172
|
-
|
|
173
|
-
| Param | Type | Default | Description |
|
|
174
|
-
| ---------------------- | -------- | ----------------------------- | -------------------------------------------------------------------------------- |
|
|
175
|
-
| `target` | `string` | — | Target address on Push Chain to execute the transaction. Can be EOA or contract. |
|
|
176
|
-
| `value` | `bigint` | - | Amount in **npush** (smallest unit) to transfer to the target address. |
|
|
177
|
-
| `data` | `string` | - | Hex-encoded calldata for the contract method to execute. |
|
|
178
|
-
| `gasLimit` | `bigint` | 21000000 | Max gas allowed for the transaction execution on Push Chain. |
|
|
179
|
-
| `maxFeePerGas` | `bigint` | 10000000000000000 | Maximum fee per unit of gas the sender is willing to pay. |
|
|
180
|
-
| `maxPriorityFeePerGas` | `bigint` | 2 | Priority tip for validators to include this tx (like EIP-1559). |
|
|
181
|
-
| `nonce` | `bigint` | Taken automatically from NMSC | Transaction execution order on Push Chain. |
|
|
182
|
-
| `deadline` | `bigint` | 9999999999 | Timestamp (in seconds) by which the tx must be included on Push Chain. |
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
## Utilities
|
|
187
|
-
|
|
188
|
-
### Converts CAIP-10 address to UniversalAccount
|
|
189
|
-
|
|
190
|
-
Converts a chain-agnostic address (e.g. `eip155:1:0xabc...`) into a UniversalAccount.
|
|
191
|
-
|
|
192
|
-
```typescript
|
|
193
|
-
const universalAccount = PushChain.utils.account.fromChainAgnostic(
|
|
194
|
-
'eip155:11155111:0x35B84d6848D16415177c64D64504663b998A6ab4'
|
|
195
|
-
);
|
|
196
|
-
// => { chain: 'ETHEREUM_SEPOLIA', address: '0x35B84d6848D16415177c64D64504663b998A6ab4' }
|
|
197
|
-
```
|
|
22
|
+
Or with yarn:
|
|
198
23
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
Converts a UniversalAccount into a chain-agnostic address (CAIP) string.
|
|
202
|
-
|
|
203
|
-
```typescript
|
|
204
|
-
const chainAgnosticStr = PushChain.utils.account.toChainAgnostic({
|
|
205
|
-
chain: 'ETHEREUM_SEPOLIA',
|
|
206
|
-
address: '0x35B84d6848D16415177c64D64504663b998A6ab4',
|
|
207
|
-
});
|
|
208
|
-
// => 'eip155:11155111:0x35B84d6848D16415177c64D64504663b998A6ab4'
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### Convert viem account or walletClient to UniversalSigner
|
|
212
|
-
|
|
213
|
-
```ts
|
|
214
|
-
import { PushChain } from '@pushchain/core';
|
|
215
|
-
import { CHAIN } from '@pushchain/core/constants/enums';
|
|
216
|
-
import { privateKeyToAccount } from 'viem/accounts';
|
|
217
|
-
|
|
218
|
-
const account = privateKeyToAccount('0x...');
|
|
219
|
-
const universalSigner = PushChain.utils.signer.toUniversalFromViem(
|
|
220
|
-
account,
|
|
221
|
-
CHAIN.ETHEREUM_SEPOLIA
|
|
222
|
-
);
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
You can also use this with viem’s `walletClient`.
|
|
226
|
-
|
|
227
|
-
---
|
|
228
|
-
|
|
229
|
-
### Convert Solana keypair to UniversalSigner
|
|
230
|
-
|
|
231
|
-
```ts
|
|
232
|
-
import { Keypair } from '@solana/web3.js';
|
|
233
|
-
import { PushChain } from '@pushchain/core';
|
|
234
|
-
import { CHAIN } from '@pushchain/core/constants/enums';
|
|
235
|
-
|
|
236
|
-
const keypair = Keypair.generate();
|
|
237
|
-
const signer = PushChain.utils.signer.toUniversalFromSolanaKeypair(
|
|
238
|
-
keypair,
|
|
239
|
-
CHAIN.SOLANA_DEVNET
|
|
240
|
-
);
|
|
24
|
+
```bash
|
|
25
|
+
yarn add @pushchain/core
|
|
241
26
|
```
|
package/package.json
CHANGED
|
@@ -12,6 +12,11 @@ export declare const FACTORY_V1: ({
|
|
|
12
12
|
name: string;
|
|
13
13
|
type: string;
|
|
14
14
|
internalType: string;
|
|
15
|
+
components: {
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
internalType: string;
|
|
19
|
+
}[];
|
|
15
20
|
}[];
|
|
16
21
|
outputs: {
|
|
17
22
|
name: string;
|
|
@@ -27,39 +32,33 @@ export declare const FACTORY_V1: ({
|
|
|
27
32
|
name: string;
|
|
28
33
|
type: string;
|
|
29
34
|
internalType: string;
|
|
35
|
+
}[];
|
|
36
|
+
outputs: ({
|
|
37
|
+
name: string;
|
|
38
|
+
type: string;
|
|
39
|
+
internalType: string;
|
|
30
40
|
components: {
|
|
31
41
|
name: string;
|
|
32
42
|
type: string;
|
|
33
43
|
internalType: string;
|
|
34
44
|
}[];
|
|
35
|
-
}
|
|
36
|
-
outputs: {
|
|
45
|
+
} | {
|
|
37
46
|
name: string;
|
|
38
47
|
type: string;
|
|
39
48
|
internalType: string;
|
|
40
|
-
|
|
49
|
+
components?: undefined;
|
|
50
|
+
})[];
|
|
41
51
|
stateMutability: string;
|
|
42
52
|
anonymous?: undefined;
|
|
43
53
|
} | {
|
|
44
54
|
type: string;
|
|
45
55
|
name: string;
|
|
46
|
-
inputs:
|
|
47
|
-
name: string;
|
|
48
|
-
type: string;
|
|
49
|
-
indexed: boolean;
|
|
50
|
-
internalType: string;
|
|
51
|
-
components?: undefined;
|
|
52
|
-
} | {
|
|
56
|
+
inputs: {
|
|
53
57
|
name: string;
|
|
54
58
|
type: string;
|
|
55
59
|
indexed: boolean;
|
|
56
60
|
internalType: string;
|
|
57
|
-
|
|
58
|
-
name: string;
|
|
59
|
-
type: string;
|
|
60
|
-
internalType: string;
|
|
61
|
-
}[];
|
|
62
|
-
})[];
|
|
61
|
+
}[];
|
|
63
62
|
anonymous: boolean;
|
|
64
63
|
stateMutability?: undefined;
|
|
65
64
|
outputs?: undefined;
|