@magicnewton/newton-protocol-sdk 0.3.17 → 0.3.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/dist/cjs/index.js +1 -1
- package/dist/cjs/types/core/exception-types.js +1 -1
- package/dist/cjs/types/core/json-rpc-types.js +1 -1
- package/dist/cjs/types/task.js +1 -1
- package/dist/es/index.js +1 -1
- package/dist/types/const.d.ts +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/modules/avs/index.d.ts +2 -2
- package/dist/types/modules/policy/index.d.ts +2 -2
- package/dist/types/sdk-exceptions.d.ts +2 -2
- package/dist/types/types/core/json-rpc-types.d.ts +5 -9
- package/dist/types/types/policy.d.ts +1 -1
- package/dist/types/types/task.d.ts +1 -1
- package/dist/types/utils/events.d.ts +3 -3
- package/dist/types/utils/intent.d.ts +2 -2
- package/dist/types/utils/promise-tools.d.ts +3 -3
- package/dist/types/utils/task.d.ts +2 -2
- package/package.json +20 -22
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var l=require("viem/chains"),
|
|
1
|
+
"use strict";var l=require("viem/chains"),A=require("./const.js"),s=require("./modules/avs/index.js"),e=require("./modules/policy/index.js");const p=[l.mainnet.id,l.sepolia.id,l.baseSepolia.id],w=(u,d)=>i=>{const{apiKey:r,policyContractAddress:n}=u,a=()=>{if(!n)throw new Error('Newton SDK: policyContractAddress is required. Ensure you instantiate viem client actions extension with policyContractAddress parameter. Example: newtonWalletClientActions({ policyContractAddress: "0x123..." })');return n};if(!p.includes(i?.chain?.id??l.sepolia.id))throw new Error(`Newton SDK: Invalid network specified for newtonWalletClientActions. Only ${p.join(", ")} are supported`);const y=d?.taskManagerAddress??A.NEWTON_PROVER_TASK_MANAGER[i?.chain?.id??l.sepolia.id],t=d?.gatewayApiUrl??void 0,c=d?.newtonIdpUrl??"https://idp.newtonproject.org";return console.log("idpUrl:",c),{submitEvaluationRequest:o=>s.submitEvaluationRequest(i,o,y,r,t),evaluateIntentDirect:o=>s.evaluateIntentDirect(i,o,r,t),submitIntentAndSubscribe:o=>s.submitIntentAndSubscribe(i,o,r,t),simulateTask:o=>s.simulateTask(i,o,r,t),simulatePolicy:o=>s.simulatePolicy(i,o,r,t),simulatePolicyData:o=>s.simulatePolicyData(i,o,r,t),simulatePolicyDataWithClient:o=>s.simulatePolicyDataWithClient(i,o,r,t),initialize:o=>{const C=a();return e.policyWriteFunctions.initialize({walletClient:i,policyContractAddress:C,...o})},renounceOwnership:()=>{const o=a();return e.policyWriteFunctions.renounceOwnership({walletClient:i,policyContractAddress:o})},transferOwnership:o=>{const C=a();return e.policyWriteFunctions.transferOwnership({walletClient:i,policyContractAddress:C,...o})},connectIdentityWithNewton:()=>Promise.resolve({foo:"bar "})}},R=(u,d)=>i=>{if(!p.includes(i?.chain?.id??l.sepolia.id))throw new Error(`Newton SDK: Invalid network specified for newtonPublicActions. Only ${p.join(", ")} are supported`);const r=u?.policyContractAddress,n=()=>{if(!r)throw new Error('Newton SDK: policyContractAddress is required. Ensure you instantiate viem client actions extension with policyContractAddress parameter. Example: newtonPublicClientActions({ policyContractAddress: "0x123..." })');return r},a=d?.taskManagerAddress??A.NEWTON_PROVER_TASK_MANAGER[i?.chain?.id??l.sepolia.id],y=d?.attestationValidatorAddress??A.ATTESTATION_VALIDATOR[i?.chain?.id??l.sepolia.id];return{waitForTaskResponded:t=>s.waitForTaskResponded(i,t,a),getTaskResponseHash:t=>s.getTaskResponseHash(i,t,a),getTaskStatus:t=>s.getTaskStatus(i,t,a,y),clientToPolicyId:t=>{const c=n();return e.policyReadFunctions.clientToPolicyId({publicClient:i,policyContractAddress:c,...t})},entrypoint:()=>{const t=n();return e.policyReadFunctions.entrypoint({publicClient:i,policyContractAddress:t})},factory:()=>{const t=n();return e.policyReadFunctions.factory({publicClient:i,policyContractAddress:t})},getEntrypoint:()=>{const t=n();return e.policyReadFunctions.getEntrypoint({publicClient:i,policyContractAddress:t})},getMetadataCid:()=>{const t=n();return e.policyReadFunctions.getMetadataCid({publicClient:i,policyContractAddress:t})},getPolicyCid:()=>{const t=n();return e.policyReadFunctions.getPolicyCid({publicClient:i,policyContractAddress:t})},getPolicyConfig:t=>{const c=n();return e.policyReadFunctions.getPolicyConfig({publicClient:i,policyContractAddress:c,...t})},getPolicyData:()=>{const t=n();return e.policyReadFunctions.getPolicyData({publicClient:i,policyContractAddress:t})},getPolicyId:t=>{const c=n();return e.policyReadFunctions.getPolicyId({publicClient:i,policyContractAddress:c,...t})},getSchemaCid:()=>{const t=n();return e.policyReadFunctions.getSchemaCid({publicClient:i,policyContractAddress:t})},isPolicyVerified:()=>{const t=n();return e.policyReadFunctions.isPolicyVerified({publicClient:i,policyContractAddress:t})},metadataCid:()=>{const t=n();return e.policyReadFunctions.metadataCid({publicClient:i,policyContractAddress:t})},owner:()=>{const t=n();return e.policyReadFunctions.owner({publicClient:i,policyContractAddress:t})},policyCid:()=>{const t=n();return e.policyReadFunctions.policyCid({publicClient:i,policyContractAddress:t})},policyData:t=>{const c=n();return e.policyReadFunctions.policyData({publicClient:i,policyContractAddress:c,...t})},schemaCid:()=>{const t=n();return e.policyReadFunctions.schemaCid({publicClient:i,policyContractAddress:t})},supportsInterface:t=>{const c=n();return e.policyReadFunctions.supportsInterface({publicClient:i,policyContractAddress:c,...t})},precomputePolicyId:t=>{const c=n();return e.policyReadFunctions.precomputePolicyId({publicClient:i,policyContractAddress:c,...t})}}};exports.newtonPublicClientActions=R,exports.newtonWalletClientActions=w;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.SDKErrorCode=void 0,function(e){e.MissingApiKey="MISSING_API_KEY",e.PopupAlreadyExists="POPUP_ALREADY_EXISTS",e.MalformedResponse="MALFORMED_RESPONSE",e.InvalidArgument="INVALID_ARGUMENT",e.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED",e.IncompatibleExtensions="INCOMPATIBLE_EXTENSIONS",e.FailedToOpenPopup="FAILED_TO_OPEN_POPUP",e.FailedToRetrieveNativeTokenBalance="FAILED_TO_RETRIEVE_NATIVE_TOKEN_BALANCE"}(exports.SDKErrorCode||(exports.SDKErrorCode={})),exports.SDKWarningCode=void 0,function(e){e.SyncWeb3Method="SYNC_WEB3_METHOD",e.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION",e.DeprecationNotice="DEPRECATION_NOTICE",e.ProductAnnouncement="ANNOUNCEMENT"}(exports.SDKWarningCode||(exports.SDKWarningCode={})),exports.RPCErrorCode=void 0,function(e){e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",e[e.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",e[e.AccessDeniedToUser=-10011]="AccessDeniedToUser",e[e.UserRejectedAction=-10012]="UserRejectedAction",e[e.RequestCancelled=-10014]="RequestCancelled",e[e.RedirectLoginComplete=-10015]="RedirectLoginComplete",e[e.NewtonWalletSessionTerminated=-10016]="NewtonWalletSessionTerminated",e[e.PopupRequestOverriden=-10017]="PopupRequestOverriden"}(exports.RPCErrorCode||(exports.RPCErrorCode={}));
|
|
1
|
+
"use strict";exports.SDKErrorCode=void 0,(function(e){e.MissingApiKey="MISSING_API_KEY",e.PopupAlreadyExists="POPUP_ALREADY_EXISTS",e.MalformedResponse="MALFORMED_RESPONSE",e.InvalidArgument="INVALID_ARGUMENT",e.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED",e.IncompatibleExtensions="INCOMPATIBLE_EXTENSIONS",e.FailedToOpenPopup="FAILED_TO_OPEN_POPUP",e.FailedToRetrieveNativeTokenBalance="FAILED_TO_RETRIEVE_NATIVE_TOKEN_BALANCE"})(exports.SDKErrorCode||(exports.SDKErrorCode={})),exports.SDKWarningCode=void 0,(function(e){e.SyncWeb3Method="SYNC_WEB3_METHOD",e.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION",e.DeprecationNotice="DEPRECATION_NOTICE",e.ProductAnnouncement="ANNOUNCEMENT"})(exports.SDKWarningCode||(exports.SDKWarningCode={})),exports.RPCErrorCode=void 0,(function(e){e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",e[e.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",e[e.AccessDeniedToUser=-10011]="AccessDeniedToUser",e[e.UserRejectedAction=-10012]="UserRejectedAction",e[e.RequestCancelled=-10014]="RequestCancelled",e[e.RedirectLoginComplete=-10015]="RedirectLoginComplete",e[e.NewtonWalletSessionTerminated=-10016]="NewtonWalletSessionTerminated",e[e.PopupRequestOverriden=-10017]="PopupRequestOverriden"})(exports.RPCErrorCode||(exports.RPCErrorCode={}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.NewtonWalletPayloadMethod=void 0,function(e){e.ShowUI="newton_wallet_wallet",e.Receive="newton_wallet_wallet_receive",e.PersonalSign="personal_sign",e.SendUserOperation="eth_sendUserOperation",e.Connect="newton_wallet_user_connect",e.Disconnect="newton_wallet_user_disconnect",e.IsConnected="newton_wallet_user_is_connected",e.GetConnectedProfile="newton_wallet_user_get_connected_profile"}(exports.NewtonWalletPayloadMethod||(exports.NewtonWalletPayloadMethod={}));
|
|
1
|
+
"use strict";exports.NewtonWalletPayloadMethod=void 0,(function(e){e.ShowUI="newton_wallet_wallet",e.Receive="newton_wallet_wallet_receive",e.PersonalSign="personal_sign",e.SendUserOperation="eth_sendUserOperation",e.Connect="newton_wallet_user_connect",e.Disconnect="newton_wallet_user_disconnect",e.IsConnected="newton_wallet_user_is_connected",e.GetConnectedProfile="newton_wallet_user_get_connected_profile"})(exports.NewtonWalletPayloadMethod||(exports.NewtonWalletPayloadMethod={}));
|
package/dist/cjs/types/task.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.TaskStatus=void 0,function(t){t.AttestationSpent="AttestationSpent",t.SuccessfullyChallenged="SuccessfullyChallenged",t.Responded="Responded",t.Created="Created",t.AttestationExpired="AttestationExpired"}(exports.TaskStatus||(exports.TaskStatus={}));
|
|
1
|
+
"use strict";exports.TaskStatus=void 0,(function(t){t.AttestationSpent="AttestationSpent",t.SuccessfullyChallenged="SuccessfullyChallenged",t.Responded="Responded",t.Created="Created",t.AttestationExpired="AttestationExpired"})(exports.TaskStatus||(exports.TaskStatus={}));
|
package/dist/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mainnet as w,sepolia as l,baseSepolia as m}from"viem/chains";import{getTaskStatus as
|
|
1
|
+
import{mainnet as w,sepolia as l,baseSepolia as m}from"viem/chains";import{NEWTON_PROVER_TASK_MANAGER as A,ATTESTATION_VALIDATOR as b}from"./const.js";import{getTaskStatus as g,getTaskResponseHash as P,waitForTaskResponded as h,simulatePolicyDataWithClient as f,simulatePolicyData as I,simulatePolicy as T,simulateTask as E,submitIntentAndSubscribe as D,evaluateIntentDirect as S,submitEvaluationRequest as k}from"./modules/avs/index.js";import{policyReadFunctions as o,policyWriteFunctions as y}from"./modules/policy/index.js";const d=[w.id,l.id,m.id],R=(p,a)=>i=>{const{apiKey:s,policyContractAddress:n}=p,c=()=>{if(!n)throw new Error('Newton SDK: policyContractAddress is required. Ensure you instantiate viem client actions extension with policyContractAddress parameter. Example: newtonWalletClientActions({ policyContractAddress: "0x123..." })');return n};if(!d.includes(i?.chain?.id??l.id))throw new Error(`Newton SDK: Invalid network specified for newtonWalletClientActions. Only ${d.join(", ")} are supported`);const u=a?.taskManagerAddress??A[i?.chain?.id??l.id],t=a?.gatewayApiUrl??void 0,r=a?.newtonIdpUrl??"https://idp.newtonproject.org";return console.log("idpUrl:",r),{submitEvaluationRequest:e=>k(i,e,u,s,t),evaluateIntentDirect:e=>S(i,e,s,t),submitIntentAndSubscribe:e=>D(i,e,s,t),simulateTask:e=>E(i,e,s,t),simulatePolicy:e=>T(i,e,s,t),simulatePolicyData:e=>I(i,e,s,t),simulatePolicyDataWithClient:e=>f(i,e,s,t),initialize:e=>{const C=c();return y.initialize({walletClient:i,policyContractAddress:C,...e})},renounceOwnership:()=>{const e=c();return y.renounceOwnership({walletClient:i,policyContractAddress:e})},transferOwnership:e=>{const C=c();return y.transferOwnership({walletClient:i,policyContractAddress:C,...e})},connectIdentityWithNewton:()=>Promise.resolve({foo:"bar "})}},O=(p,a)=>i=>{if(!d.includes(i?.chain?.id??l.id))throw new Error(`Newton SDK: Invalid network specified for newtonPublicActions. Only ${d.join(", ")} are supported`);const s=p?.policyContractAddress,n=()=>{if(!s)throw new Error('Newton SDK: policyContractAddress is required. Ensure you instantiate viem client actions extension with policyContractAddress parameter. Example: newtonPublicClientActions({ policyContractAddress: "0x123..." })');return s},c=a?.taskManagerAddress??A[i?.chain?.id??l.id],u=a?.attestationValidatorAddress??b[i?.chain?.id??l.id];return{waitForTaskResponded:t=>h(i,t,c),getTaskResponseHash:t=>P(i,t,c),getTaskStatus:t=>g(i,t,c,u),clientToPolicyId:t=>{const r=n();return o.clientToPolicyId({publicClient:i,policyContractAddress:r,...t})},entrypoint:()=>{const t=n();return o.entrypoint({publicClient:i,policyContractAddress:t})},factory:()=>{const t=n();return o.factory({publicClient:i,policyContractAddress:t})},getEntrypoint:()=>{const t=n();return o.getEntrypoint({publicClient:i,policyContractAddress:t})},getMetadataCid:()=>{const t=n();return o.getMetadataCid({publicClient:i,policyContractAddress:t})},getPolicyCid:()=>{const t=n();return o.getPolicyCid({publicClient:i,policyContractAddress:t})},getPolicyConfig:t=>{const r=n();return o.getPolicyConfig({publicClient:i,policyContractAddress:r,...t})},getPolicyData:()=>{const t=n();return o.getPolicyData({publicClient:i,policyContractAddress:t})},getPolicyId:t=>{const r=n();return o.getPolicyId({publicClient:i,policyContractAddress:r,...t})},getSchemaCid:()=>{const t=n();return o.getSchemaCid({publicClient:i,policyContractAddress:t})},isPolicyVerified:()=>{const t=n();return o.isPolicyVerified({publicClient:i,policyContractAddress:t})},metadataCid:()=>{const t=n();return o.metadataCid({publicClient:i,policyContractAddress:t})},owner:()=>{const t=n();return o.owner({publicClient:i,policyContractAddress:t})},policyCid:()=>{const t=n();return o.policyCid({publicClient:i,policyContractAddress:t})},policyData:t=>{const r=n();return o.policyData({publicClient:i,policyContractAddress:r,...t})},schemaCid:()=>{const t=n();return o.schemaCid({publicClient:i,policyContractAddress:t})},supportsInterface:t=>{const r=n();return o.supportsInterface({publicClient:i,policyContractAddress:r,...t})},precomputePolicyId:t=>{const r=n();return o.precomputePolicyId({publicClient:i,policyContractAddress:r,...t})}}};export{O as newtonPublicClientActions,R as newtonWalletClientActions};
|
package/dist/types/const.d.ts
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Address, Hex } from 'viem';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { Address, Hex } from 'viem';
|
|
2
|
+
import { type PendingTaskBuilder } from './modules/avs';
|
|
3
|
+
import type { SimulatePolicyDataParams, SimulatePolicyDataResult, SimulatePolicyDataWithClientParams, SimulatePolicyDataWithClientResult, SimulatePolicyParams, SimulatePolicyResult, SimulateTaskParams, SimulateTaskResult, SubmitEvaluationRequestParams, SubmitIntentResult, Task, TaskId, TaskResponseResult, TaskStatus } from './types/task';
|
|
4
4
|
interface SdkOverrides {
|
|
5
5
|
gatewayApiUrl?: string;
|
|
6
6
|
taskManagerAddress?: Address;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PublicClient as Client,
|
|
1
|
+
import { type SimulatePolicyDataParams, type SimulatePolicyDataResult, type SimulatePolicyDataWithClientParams, type SimulatePolicyDataWithClientResult, type SimulatePolicyParams, type SimulatePolicyResult, type SimulateTaskParams, type SimulateTaskResult, type SubmitEvaluationRequestParams, type SubmitIntentResult, type Task, type TaskId, type TaskResponseResult, TaskStatus } from '../../types/task';
|
|
2
|
+
import { type Address, type PublicClient as Client, type Hex, type WalletClient } from 'viem';
|
|
3
3
|
export interface CreateTaskResult {
|
|
4
4
|
task_id: Hex;
|
|
5
5
|
task_request: any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PolicyId, PolicyParamsJson } from '../../types/policy';
|
|
2
|
-
import { PublicClient, WalletClient
|
|
1
|
+
import type { PolicyId, PolicyParamsJson } from '../../types/policy';
|
|
2
|
+
import { type Address, type PublicClient, type WalletClient } from 'viem';
|
|
3
3
|
export declare const policyWriteFunctions: {
|
|
4
4
|
initialize: ({ walletClient, policyContractAddress, ...args }: {
|
|
5
5
|
walletClient: WalletClient;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RPCErrorCode, SDKErrorCode } from './types/core/exception-types';
|
|
2
|
-
import { JsonRpcError } from './types/core/json-rpc-types';
|
|
1
|
+
import { RPCErrorCode, type SDKErrorCode } from './types/core/exception-types';
|
|
2
|
+
import type { JsonRpcError } from './types/core/json-rpc-types';
|
|
3
3
|
export declare class SDKError extends Error {
|
|
4
4
|
code: SDKErrorCode;
|
|
5
5
|
rawMessage: string;
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { RPCErrorCode } from '../../../types';
|
|
1
|
+
import type { RPCErrorCode } from '../../../types';
|
|
2
2
|
export interface JsonRpcRequestPayload<TParams = any> {
|
|
3
3
|
jsonrpc: string;
|
|
4
4
|
id: string | number | null;
|
|
5
5
|
method: string;
|
|
6
6
|
params?: TParams;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export interface JsonRpcBatchRequestCallback {
|
|
13
|
-
/** Callback executed upon JSON RPC response. */
|
|
14
|
-
(err: JsonRpcError | null, result?: (JsonRpcResponsePayload | null)[] | null): void;
|
|
15
|
-
}
|
|
8
|
+
/** Callback executed upon JSON RPC response. */
|
|
9
|
+
export type JsonRpcRequestCallback = (err: JsonRpcError | null, result?: JsonRpcResponsePayload | null) => void;
|
|
10
|
+
/** Callback executed upon JSON RPC response. */
|
|
11
|
+
export type JsonRpcBatchRequestCallback = (err: JsonRpcError | null, result?: (JsonRpcResponsePayload | null)[] | null) => void;
|
|
16
12
|
export interface ShowUIParams {
|
|
17
13
|
page?: 'swap' | string;
|
|
18
14
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
2
|
export type EventsDefinition = {
|
|
3
3
|
[K in string | symbol]: (...args: any[]) => void;
|
|
4
|
-
} |
|
|
4
|
+
} | undefined;
|
|
5
5
|
/**
|
|
6
6
|
* An extension of `EventEmitter` (provided by `eventemitter3`) with an adjusted
|
|
7
7
|
* type interface that supports the unique structure of Newton Wallet SDK modules.
|
|
8
8
|
*/
|
|
9
|
-
export declare class TypedEmitter<Events extends EventsDefinition =
|
|
9
|
+
export declare class TypedEmitter<Events extends EventsDefinition = undefined> extends EventEmitter<Events extends undefined ? string | symbol : Events> {
|
|
10
10
|
}
|
|
11
11
|
type ChainingMethods = 'on' | 'once' | 'addListener' | 'off' | 'removeListener' | 'removeAllListeners';
|
|
12
12
|
type NonChainingMethods = 'emit' | 'eventNames' | 'listeners' | 'listenerCount';
|
|
@@ -15,7 +15,7 @@ type ReplaceReturnType<T extends (...a: any) => any, TNewReturn> = (...a: Parame
|
|
|
15
15
|
* Creates a `TypedEmitter` instance and returns helper functions for easily
|
|
16
16
|
* mixing `TypedEmitter` methods into other objects.
|
|
17
17
|
*/
|
|
18
|
-
export declare function createTypedEmitter<Events extends EventsDefinition =
|
|
18
|
+
export declare function createTypedEmitter<Events extends EventsDefinition = undefined>(): {
|
|
19
19
|
emitter: TypedEmitter<Events>;
|
|
20
20
|
createChainingEmitterMethod: <T1 extends ChainingMethods, T2>(method: T1, source: T2) => ReplaceReturnType<TypedEmitter[T1], T2>;
|
|
21
21
|
createBoundEmitterMethod: <T extends NonChainingMethods>(method: T) => TypedEmitter[T];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HexlifiedIntent, IntentFromParams, NormalizedIntent } from '../types/task';
|
|
2
|
-
import { Hex } from 'viem';
|
|
1
|
+
import type { HexlifiedIntent, IntentFromParams, NormalizedIntent } from '../types/task';
|
|
2
|
+
import { type Hex } from 'viem';
|
|
3
3
|
export declare const removeHexPrefix: (input: Hex) => string;
|
|
4
4
|
export declare function normalizeIntent(intent: IntentFromParams): NormalizedIntent;
|
|
5
5
|
export declare function sanitizeIntentForRequest(intent: IntentFromParams): HexlifiedIntent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type EventsDefinition, type TypedEmitter } from './events';
|
|
2
2
|
/**
|
|
3
3
|
* Extends `Promise` with a polymorphic `this` type to accomodate arbitrary
|
|
4
4
|
* `Promise` API extensions.
|
|
@@ -11,7 +11,7 @@ interface ExtendedPromise<T> extends Promise<T> {
|
|
|
11
11
|
/**
|
|
12
12
|
* A `Promise` and `EventEmitter` all in one!
|
|
13
13
|
*/
|
|
14
|
-
export type PromiEvent<TResult, TEvents extends EventsDefinition =
|
|
14
|
+
export type PromiEvent<TResult, TEvents extends EventsDefinition = undefined> = ExtendedPromise<TResult> & TypedEmitter<TEvents extends undefined ? DefaultEvents<TResult> : TEvents & DefaultEvents<TResult>>;
|
|
15
15
|
/**
|
|
16
16
|
* Default events attached to every `PromiEvent`.
|
|
17
17
|
*/
|
|
@@ -32,7 +32,7 @@ export declare function isPromiEvent(value: any): value is PromiEvent<any>;
|
|
|
32
32
|
* Create a native JavaScript `Promise` overloaded with strongly-typed methods
|
|
33
33
|
* from `EventEmitter`.
|
|
34
34
|
*/
|
|
35
|
-
export declare function createPromiEvent<TResult, TEvents extends EventsDefinition =
|
|
35
|
+
export declare function createPromiEvent<TResult, TEvents extends EventsDefinition = undefined>(executor: AsyncPromiseExecutor<TResult>): PromiEvent<TResult, TEvents extends undefined ? DefaultEvents<TResult> : TEvents & DefaultEvents<TResult>>;
|
|
36
36
|
/**
|
|
37
37
|
* Creates a `Promise` with an **async executor** that automatically catches
|
|
38
38
|
* errors occurring within the executor. Nesting promises in this way is usually
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { TaskRespondedLog } from '../abis/newtonAbi';
|
|
2
|
+
import type { TaskResponseResult } from '../types/task';
|
|
3
3
|
export declare function convertLogToTaskResponse(log: TaskRespondedLog): TaskResponseResult;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicnewton/newton-protocol-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.18",
|
|
4
4
|
"description": "Official SDK for the Newton Protocol.",
|
|
5
5
|
"author": "Newton Foundation <https://x.com/newtfoundation> (https://newton.foundation)",
|
|
6
6
|
"private": false,
|
|
@@ -47,12 +47,17 @@
|
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"preinstall": "npx only-allow pnpm",
|
|
50
|
-
"prepare": "
|
|
50
|
+
"prepare": "simple-git-hooks",
|
|
51
51
|
"build": "rollup -c rollup.config.mjs",
|
|
52
|
-
"lint": "
|
|
53
|
-
"
|
|
54
|
-
"format
|
|
55
|
-
"
|
|
52
|
+
"lint": "biome check src/",
|
|
53
|
+
"lint:fix": "biome check --write src/",
|
|
54
|
+
"format": "biome format --write src/",
|
|
55
|
+
"format:check": "biome format src/",
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"test:watch": "vitest",
|
|
59
|
+
"test:coverage": "vitest run --coverage",
|
|
60
|
+
"sync-abis": "./scripts/sync-abis.sh",
|
|
56
61
|
"clean": "rimraf dist && rimraf node_modules"
|
|
57
62
|
},
|
|
58
63
|
"auto": {
|
|
@@ -63,38 +68,31 @@
|
|
|
63
68
|
]
|
|
64
69
|
},
|
|
65
70
|
"devDependencies": {
|
|
66
|
-
"@
|
|
71
|
+
"@biomejs/biome": "^1.9.4",
|
|
67
72
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
68
73
|
"@types/rimraf": "^4.0.5",
|
|
69
|
-
"@typescript-eslint/eslint-plugin": "^7.12.0",
|
|
70
|
-
"@typescript-eslint/parser": "^7.12.0",
|
|
71
|
-
"auto": "^11.1.2",
|
|
72
74
|
"builtin-modules": "^4.0.0",
|
|
73
|
-
"eslint": "^8.56.0",
|
|
74
|
-
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
75
|
-
"eslint-config-prettier": "^10.1.8",
|
|
76
|
-
"eslint-plugin-import": "^2.31.0",
|
|
77
|
-
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
78
|
-
"eslint-plugin-prettier": "^5.1.3",
|
|
79
|
-
"eslint-plugin-react": "^7.37.5",
|
|
80
|
-
"eslint-plugin-react-hooks": "^5.2.0",
|
|
81
|
-
"husky": "^9.1.6",
|
|
82
|
-
"lint-staged": "^15.2.10",
|
|
83
|
-
"prettier": "^3.6.2",
|
|
84
75
|
"rimraf": "^6.0.1",
|
|
85
76
|
"rollup": "^4.48.1",
|
|
86
77
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
87
78
|
"rollup-plugin-node-externals": "^8.1.0",
|
|
88
79
|
"rollup-plugin-tsc-alias": "^1.1.4",
|
|
89
80
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
81
|
+
"@auto-it/conventional-commits": "^11.3.0",
|
|
82
|
+
"auto": "^11.3.0",
|
|
83
|
+
"simple-git-hooks": "^2.11.1",
|
|
90
84
|
"ts-node": "^10.9.2",
|
|
91
|
-
"typescript": "^5.4.5"
|
|
85
|
+
"typescript": "^5.4.5",
|
|
86
|
+
"vitest": "^3.1.1"
|
|
92
87
|
},
|
|
93
88
|
"dependencies": {
|
|
94
89
|
"eventemitter3": "^4.0.4",
|
|
95
90
|
"jose": "^6.0.13",
|
|
96
91
|
"viem": "^2.35.1"
|
|
97
92
|
},
|
|
93
|
+
"simple-git-hooks": {
|
|
94
|
+
"pre-commit": "pnpm lint"
|
|
95
|
+
},
|
|
98
96
|
"externals": {
|
|
99
97
|
"exclude": [
|
|
100
98
|
"eventemitter3",
|