near-safe 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/lib/bundler.d.ts +2 -1
- package/dist/cjs/lib/bundler.js +12 -0
- package/dist/cjs/near-safe.d.ts +2 -1
- package/dist/cjs/near-safe.js +4 -1
- package/dist/cjs/types.d.ts +27 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/bundler.d.ts +2 -1
- package/dist/esm/lib/bundler.js +12 -0
- package/dist/esm/near-safe.d.ts +2 -1
- package/dist/esm/near-safe.js +4 -1
- package/dist/esm/types.d.ts +27 -0
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
@@ -2,4 +2,4 @@ export * from "./near-safe";
|
|
2
2
|
export * from "./types";
|
3
3
|
export * from "./util";
|
4
4
|
export * from "./constants";
|
5
|
-
export { Network, BaseTx, SignRequestData, populateTx } from "near-ca";
|
5
|
+
export { Network, BaseTx, SignRequestData, populateTx, NetworkFields, } from "near-ca";
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Address, Hash, PublicClient, Transport } from "viem";
|
2
|
-
import { GasPrices, PaymasterData, UnsignedUserOperation, UserOperation, UserOperationReceipt } from "../types";
|
2
|
+
import { GasPrices, PaymasterData, SponsorshipPolicyData, UnsignedUserOperation, UserOperation, UserOperationReceipt } from "../types";
|
3
3
|
type SponsorshipPolicy = {
|
4
4
|
sponsorshipPolicyId: string;
|
5
5
|
};
|
@@ -36,6 +36,7 @@ export declare class Erc4337Bundler {
|
|
36
36
|
getGasPrice(): Promise<GasPrices>;
|
37
37
|
getUserOpReceipt(userOpHash: Hash): Promise<UserOperationReceipt>;
|
38
38
|
private _getUserOpReceiptInner;
|
39
|
+
getSponsorshipPolicies(): Promise<SponsorshipPolicyData[]>;
|
39
40
|
}
|
40
41
|
export declare function stripApiKey(error: unknown): string;
|
41
42
|
export {};
|
package/dist/cjs/lib/bundler.js
CHANGED
@@ -60,6 +60,18 @@ class Erc4337Bundler {
|
|
60
60
|
params: [userOpHash],
|
61
61
|
}));
|
62
62
|
}
|
63
|
+
// New method to query sponsorship policies
|
64
|
+
async getSponsorshipPolicies() {
|
65
|
+
const url = `https://api.pimlico.io/v2/account/sponsorship_policies?apikey=${this.apiKey}`;
|
66
|
+
const allPolocies = await handleRequest(async () => {
|
67
|
+
const response = await fetch(url);
|
68
|
+
if (!response.ok) {
|
69
|
+
throw new Error(`HTTP error! status: ${response.status}: ${response.statusText}`);
|
70
|
+
}
|
71
|
+
return response.json();
|
72
|
+
});
|
73
|
+
return allPolocies.data.filter((p) => p.chain_ids.allowlist.includes(this.chainId));
|
74
|
+
}
|
63
75
|
}
|
64
76
|
exports.Erc4337Bundler = Erc4337Bundler;
|
65
77
|
async function handleRequest(clientMethod) {
|
package/dist/cjs/near-safe.d.ts
CHANGED
@@ -3,7 +3,7 @@ import { FinalExecutionOutcome } from "near-api-js/lib/providers";
|
|
3
3
|
import { NearEthAdapter, SignRequestData } from "near-ca";
|
4
4
|
import { Address, Hash, Hex } from "viem";
|
5
5
|
import { SafeContractSuite } from "./lib/safe";
|
6
|
-
import { DecodedMultisend, EncodedTxData, EvmTransactionData, MetaTransaction, UserOperation, UserOperationReceipt } from "./types";
|
6
|
+
import { DecodedMultisend, EncodedTxData, EvmTransactionData, MetaTransaction, SponsorshipPolicyData, UserOperation, UserOperationReceipt } from "./types";
|
7
7
|
export interface NearSafeConfig {
|
8
8
|
accountId: string;
|
9
9
|
mpcContractId: string;
|
@@ -178,4 +178,5 @@ export declare class NearSafe {
|
|
178
178
|
payload: number[];
|
179
179
|
hash: Hash;
|
180
180
|
}>;
|
181
|
+
policyForChainId(chainId: number): Promise<SponsorshipPolicyData[]>;
|
181
182
|
}
|
package/dist/cjs/near-safe.js
CHANGED
@@ -92,7 +92,6 @@ class NearSafe {
|
|
92
92
|
if (transactions.length === 0) {
|
93
93
|
throw new Error("Empty transaction set!");
|
94
94
|
}
|
95
|
-
console.log(`Building UserOp on chainId ${chainId} with ${transactions.length} transaction(s)`);
|
96
95
|
const bundler = this.bundlerForChainId(chainId);
|
97
96
|
const [gasFees, nonce, safeDeployed] = await Promise.all([
|
98
97
|
bundler.getGasPrice(),
|
@@ -330,5 +329,9 @@ class NearSafe {
|
|
330
329
|
}
|
331
330
|
}
|
332
331
|
}
|
332
|
+
async policyForChainId(chainId) {
|
333
|
+
const bundler = this.bundlerForChainId(chainId);
|
334
|
+
return bundler.getSponsorshipPolicies();
|
335
|
+
}
|
333
336
|
}
|
334
337
|
exports.NearSafe = NearSafe;
|
package/dist/cjs/types.d.ts
CHANGED
@@ -246,4 +246,31 @@ export interface EncodedTxData {
|
|
246
246
|
request: SignArgs;
|
247
247
|
}>;
|
248
248
|
}
|
249
|
+
export interface SponsorshipPoliciesResponse {
|
250
|
+
has_more: boolean;
|
251
|
+
data: SponsorshipPolicyData[];
|
252
|
+
}
|
253
|
+
export interface SponsorshipPolicyData {
|
254
|
+
id: string;
|
255
|
+
policy_name: string;
|
256
|
+
limits: PolicyLimits;
|
257
|
+
start_time: string;
|
258
|
+
end_time: string;
|
259
|
+
chain_ids: ChainIds;
|
260
|
+
policy_status: string;
|
261
|
+
created_at: string;
|
262
|
+
}
|
263
|
+
export interface PolicyLimits {
|
264
|
+
global: GlobalLimits;
|
265
|
+
}
|
266
|
+
export interface GlobalLimits {
|
267
|
+
user_operation_spending: SpendingLimit;
|
268
|
+
}
|
269
|
+
export interface SpendingLimit {
|
270
|
+
amount: number;
|
271
|
+
currency: string;
|
272
|
+
}
|
273
|
+
export interface ChainIds {
|
274
|
+
allowlist: number[];
|
275
|
+
}
|
249
276
|
export {};
|
package/dist/esm/index.d.ts
CHANGED
@@ -2,4 +2,4 @@ export * from "./near-safe";
|
|
2
2
|
export * from "./types";
|
3
3
|
export * from "./util";
|
4
4
|
export * from "./constants";
|
5
|
-
export { Network, BaseTx, SignRequestData, populateTx } from "near-ca";
|
5
|
+
export { Network, BaseTx, SignRequestData, populateTx, NetworkFields, } from "near-ca";
|
package/dist/esm/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Address, Hash, PublicClient, Transport } from "viem";
|
2
|
-
import { GasPrices, PaymasterData, UnsignedUserOperation, UserOperation, UserOperationReceipt } from "../types";
|
2
|
+
import { GasPrices, PaymasterData, SponsorshipPolicyData, UnsignedUserOperation, UserOperation, UserOperationReceipt } from "../types";
|
3
3
|
type SponsorshipPolicy = {
|
4
4
|
sponsorshipPolicyId: string;
|
5
5
|
};
|
@@ -36,6 +36,7 @@ export declare class Erc4337Bundler {
|
|
36
36
|
getGasPrice(): Promise<GasPrices>;
|
37
37
|
getUserOpReceipt(userOpHash: Hash): Promise<UserOperationReceipt>;
|
38
38
|
private _getUserOpReceiptInner;
|
39
|
+
getSponsorshipPolicies(): Promise<SponsorshipPolicyData[]>;
|
39
40
|
}
|
40
41
|
export declare function stripApiKey(error: unknown): string;
|
41
42
|
export {};
|
package/dist/esm/lib/bundler.js
CHANGED
@@ -60,6 +60,18 @@ export class Erc4337Bundler {
|
|
60
60
|
params: [userOpHash],
|
61
61
|
}));
|
62
62
|
}
|
63
|
+
// New method to query sponsorship policies
|
64
|
+
async getSponsorshipPolicies() {
|
65
|
+
const url = `https://api.pimlico.io/v2/account/sponsorship_policies?apikey=${this.apiKey}`;
|
66
|
+
const allPolocies = await handleRequest(async () => {
|
67
|
+
const response = await fetch(url);
|
68
|
+
if (!response.ok) {
|
69
|
+
throw new Error(`HTTP error! status: ${response.status}: ${response.statusText}`);
|
70
|
+
}
|
71
|
+
return response.json();
|
72
|
+
});
|
73
|
+
return allPolocies.data.filter((p) => p.chain_ids.allowlist.includes(this.chainId));
|
74
|
+
}
|
63
75
|
}
|
64
76
|
async function handleRequest(clientMethod) {
|
65
77
|
try {
|
package/dist/esm/near-safe.d.ts
CHANGED
@@ -3,7 +3,7 @@ import { FinalExecutionOutcome } from "near-api-js/lib/providers";
|
|
3
3
|
import { NearEthAdapter, SignRequestData } from "near-ca";
|
4
4
|
import { Address, Hash, Hex } from "viem";
|
5
5
|
import { SafeContractSuite } from "./lib/safe";
|
6
|
-
import { DecodedMultisend, EncodedTxData, EvmTransactionData, MetaTransaction, UserOperation, UserOperationReceipt } from "./types";
|
6
|
+
import { DecodedMultisend, EncodedTxData, EvmTransactionData, MetaTransaction, SponsorshipPolicyData, UserOperation, UserOperationReceipt } from "./types";
|
7
7
|
export interface NearSafeConfig {
|
8
8
|
accountId: string;
|
9
9
|
mpcContractId: string;
|
@@ -178,4 +178,5 @@ export declare class NearSafe {
|
|
178
178
|
payload: number[];
|
179
179
|
hash: Hash;
|
180
180
|
}>;
|
181
|
+
policyForChainId(chainId: number): Promise<SponsorshipPolicyData[]>;
|
181
182
|
}
|
package/dist/esm/near-safe.js
CHANGED
@@ -95,7 +95,6 @@ export class NearSafe {
|
|
95
95
|
if (transactions.length === 0) {
|
96
96
|
throw new Error("Empty transaction set!");
|
97
97
|
}
|
98
|
-
console.log(`Building UserOp on chainId ${chainId} with ${transactions.length} transaction(s)`);
|
99
98
|
const bundler = this.bundlerForChainId(chainId);
|
100
99
|
const [gasFees, nonce, safeDeployed] = await Promise.all([
|
101
100
|
bundler.getGasPrice(),
|
@@ -333,4 +332,8 @@ export class NearSafe {
|
|
333
332
|
}
|
334
333
|
}
|
335
334
|
}
|
335
|
+
async policyForChainId(chainId) {
|
336
|
+
const bundler = this.bundlerForChainId(chainId);
|
337
|
+
return bundler.getSponsorshipPolicies();
|
338
|
+
}
|
336
339
|
}
|
package/dist/esm/types.d.ts
CHANGED
@@ -246,4 +246,31 @@ export interface EncodedTxData {
|
|
246
246
|
request: SignArgs;
|
247
247
|
}>;
|
248
248
|
}
|
249
|
+
export interface SponsorshipPoliciesResponse {
|
250
|
+
has_more: boolean;
|
251
|
+
data: SponsorshipPolicyData[];
|
252
|
+
}
|
253
|
+
export interface SponsorshipPolicyData {
|
254
|
+
id: string;
|
255
|
+
policy_name: string;
|
256
|
+
limits: PolicyLimits;
|
257
|
+
start_time: string;
|
258
|
+
end_time: string;
|
259
|
+
chain_ids: ChainIds;
|
260
|
+
policy_status: string;
|
261
|
+
created_at: string;
|
262
|
+
}
|
263
|
+
export interface PolicyLimits {
|
264
|
+
global: GlobalLimits;
|
265
|
+
}
|
266
|
+
export interface GlobalLimits {
|
267
|
+
user_operation_spending: SpendingLimit;
|
268
|
+
}
|
269
|
+
export interface SpendingLimit {
|
270
|
+
amount: number;
|
271
|
+
currency: string;
|
272
|
+
}
|
273
|
+
export interface ChainIds {
|
274
|
+
allowlist: number[];
|
275
|
+
}
|
249
276
|
export {};
|