Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mysten/enoki

Package Overview
Dependencies
Maintainers
4
Versions
206
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mysten/enoki - npm Package Compare versions

Comparing version 0.0.0-experimental-20231129041929 to 0.0.0-experimental-20231130015447

7

CHANGELOG.md
# @mysten/enoki
## 0.0.0-experimental-20231129041929
## 0.0.0-experimental-20231130015447
### Patch Changes
- dd485449a: Update to new two-step API
- Updated dependencies [cdcfa76c4]
- @mysten/sui.js@0.0.0-experimental-20231129041929
- @mysten/zklogin@0.0.0-experimental-20231129041929
- @mysten/sui.js@0.0.0-experimental-20231130015447
- @mysten/zklogin@0.0.0-experimental-20231130015447

@@ -11,0 +12,0 @@ ## 0.0.6

@@ -1,2 +0,2 @@

import type { CreateSponsoredTransactionBlockApiInput, CreateSponsoredTransactionBlockApiResponse, CreateZkLoginNonceApiInput, CreateZkLoginNonceApiResponse, CreateZkLoginZkpApiInput, CreateZkLoginZkpApiResponse, GetAppApiInput, GetAppApiResponse, GetZkLoginApiInput, GetZkLoginApiResponse } from './type.js';
import type { CreateSponsoredTransactionBlockApiInput, CreateSponsoredTransactionBlockApiResponse, CreateZkLoginNonceApiInput, CreateZkLoginNonceApiResponse, CreateZkLoginZkpApiInput, CreateZkLoginZkpApiResponse, ExecuteSponsoredTransactionBlockApiInput, ExecuteSponsoredTransactionBlockApiResponse, GetAppApiInput, GetAppApiResponse, GetZkLoginApiInput, GetZkLoginApiResponse } from './type.js';
export interface EnokiClientConfig {

@@ -19,2 +19,3 @@ /** The API key for the Enoki app, available in the Enoki Portal. */

createSponsoredTransactionBlock(input: CreateSponsoredTransactionBlockApiInput): Promise<CreateSponsoredTransactionBlockApiResponse>;
executeSponsoredTransactionBlock(input: ExecuteSponsoredTransactionBlockApiInput): Promise<ExecuteSponsoredTransactionBlockApiResponse>;
}

@@ -105,2 +105,10 @@ "use strict";

}
executeSponsoredTransactionBlock(input) {
return __privateMethod(this, _fetch, fetch_fn).call(this, `transaction-blocks/sponsor/${input.digest}`, {
method: "POST",
body: JSON.stringify({
signature: input.signature
})
});
}
}

@@ -107,0 +115,0 @@ _version = new WeakMap();

@@ -44,6 +44,10 @@ import type { PublicKey } from '@mysten/sui.js/cryptography';

bytes: string;
digest: string;
}
export interface ExecuteSponsoredTransactionBlockApiInput {
digest: string;
signature: string;
}
export interface ExecuteSponsoredTransactionBlockApiResponse {
digest: string;
expireAtTime: number;
expireAfterEpoch: number;
}

@@ -1,2 +0,2 @@

import type { ExecuteTransactionBlockParams, SuiClient } from '@mysten/sui.js/client';
import type { SuiClient } from '@mysten/sui.js/client';
import type { TransactionBlock } from '@mysten/sui.js/transactions';

@@ -56,7 +56,21 @@ import type { ZkLoginSignatureInputs } from '@mysten/sui.js/zklogin';

getKeypair(): Promise<EnokiKeypair>;
sponsorAndExecuteTransactionBlock({ network, transactionBlock, client, ...options }: {
sponsorTransactionBlock({ network, transactionBlock, client, }: {
network?: 'mainnet' | 'testnet';
transactionBlock: TransactionBlock;
client: SuiClient;
} & Omit<ExecuteTransactionBlockParams, 'signature' | 'transactionBlock'>): Promise<import("@mysten/sui.js/client").SuiTransactionBlockResponse>;
}): Promise<import("./EnokiClient/type.js").CreateSponsoredTransactionBlockApiResponse>;
executeTransactionBlock({ bytes, digest, client, }: {
bytes: string;
digest: string;
client: SuiClient;
}): Promise<{
digest: string;
}>;
sponsorAndExecuteTransactionBlock({ network, transactionBlock, client, }: {
network?: 'mainnet' | 'testnet';
transactionBlock: TransactionBlock;
client: SuiClient;
}): Promise<{
digest: string;
}>;
}

@@ -238,10 +238,11 @@ "use strict";

}
async sponsorAndExecuteTransactionBlock({
async sponsorTransactionBlock({
network,
transactionBlock,
client,
...options
client
}) {
const session = await this.getSession();
const keypair = await this.getKeypair();
if (!session || !session.jwt) {
throw new Error("Missing required data for sponsorship.");
}
const transactionBlockKindBytes = await transactionBlock.build({

@@ -258,3 +259,3 @@ onlyTransactionKind: true,

});
const { bytes, signature: sponsorSignature } = await __privateGet(this, _enokiClient).createSponsoredTransactionBlock({
return await __privateGet(this, _enokiClient).createSponsoredTransactionBlock({
jwt: session.jwt,

@@ -264,9 +265,29 @@ network,

});
}
async executeTransactionBlock({
bytes,
digest,
client
}) {
const keypair = await this.getKeypair();
const userSignature = await keypair.signTransactionBlock((0, import_utils.fromB64)(bytes));
return client.executeTransactionBlock({
transactionBlock: bytes,
signature: [userSignature.signature, sponsorSignature],
...options
await __privateGet(this, _enokiClient).executeSponsoredTransactionBlock({
digest,
signature: userSignature.signature
});
await client.waitForTransactionBlock({ digest });
return { digest };
}
async sponsorAndExecuteTransactionBlock({
network,
transactionBlock,
client
}) {
const { bytes, digest } = await this.sponsorTransactionBlock({
network,
transactionBlock,
client
});
return await this.executeTransactionBlock({ bytes, digest, client });
}
}

@@ -273,0 +294,0 @@ _storageKeys = new WeakMap();

@@ -1,2 +0,2 @@

import type { CreateSponsoredTransactionBlockApiInput, CreateSponsoredTransactionBlockApiResponse, CreateZkLoginNonceApiInput, CreateZkLoginNonceApiResponse, CreateZkLoginZkpApiInput, CreateZkLoginZkpApiResponse, GetAppApiInput, GetAppApiResponse, GetZkLoginApiInput, GetZkLoginApiResponse } from './type.js';
import type { CreateSponsoredTransactionBlockApiInput, CreateSponsoredTransactionBlockApiResponse, CreateZkLoginNonceApiInput, CreateZkLoginNonceApiResponse, CreateZkLoginZkpApiInput, CreateZkLoginZkpApiResponse, ExecuteSponsoredTransactionBlockApiInput, ExecuteSponsoredTransactionBlockApiResponse, GetAppApiInput, GetAppApiResponse, GetZkLoginApiInput, GetZkLoginApiResponse } from './type.js';
export interface EnokiClientConfig {

@@ -19,2 +19,3 @@ /** The API key for the Enoki app, available in the Enoki Portal. */

createSponsoredTransactionBlock(input: CreateSponsoredTransactionBlockApiInput): Promise<CreateSponsoredTransactionBlockApiResponse>;
executeSponsoredTransactionBlock(input: ExecuteSponsoredTransactionBlockApiInput): Promise<ExecuteSponsoredTransactionBlockApiResponse>;
}

@@ -82,2 +82,10 @@ var __accessCheck = (obj, member, msg) => {

}
executeSponsoredTransactionBlock(input) {
return __privateMethod(this, _fetch, fetch_fn).call(this, `transaction-blocks/sponsor/${input.digest}`, {
method: "POST",
body: JSON.stringify({
signature: input.signature
})
});
}
}

@@ -84,0 +92,0 @@ _version = new WeakMap();

@@ -44,6 +44,10 @@ import type { PublicKey } from '@mysten/sui.js/cryptography';

bytes: string;
digest: string;
}
export interface ExecuteSponsoredTransactionBlockApiInput {
digest: string;
signature: string;
}
export interface ExecuteSponsoredTransactionBlockApiResponse {
digest: string;
expireAtTime: number;
expireAfterEpoch: number;
}

@@ -1,2 +0,2 @@

import type { ExecuteTransactionBlockParams, SuiClient } from '@mysten/sui.js/client';
import type { SuiClient } from '@mysten/sui.js/client';
import type { TransactionBlock } from '@mysten/sui.js/transactions';

@@ -56,7 +56,21 @@ import type { ZkLoginSignatureInputs } from '@mysten/sui.js/zklogin';

getKeypair(): Promise<EnokiKeypair>;
sponsorAndExecuteTransactionBlock({ network, transactionBlock, client, ...options }: {
sponsorTransactionBlock({ network, transactionBlock, client, }: {
network?: 'mainnet' | 'testnet';
transactionBlock: TransactionBlock;
client: SuiClient;
} & Omit<ExecuteTransactionBlockParams, 'signature' | 'transactionBlock'>): Promise<import("@mysten/sui.js/client").SuiTransactionBlockResponse>;
}): Promise<import("./EnokiClient/type.js").CreateSponsoredTransactionBlockApiResponse>;
executeTransactionBlock({ bytes, digest, client, }: {
bytes: string;
digest: string;
client: SuiClient;
}): Promise<{
digest: string;
}>;
sponsorAndExecuteTransactionBlock({ network, transactionBlock, client, }: {
network?: 'mainnet' | 'testnet';
transactionBlock: TransactionBlock;
client: SuiClient;
}): Promise<{
digest: string;
}>;
}

@@ -215,10 +215,11 @@ var __accessCheck = (obj, member, msg) => {

}
async sponsorAndExecuteTransactionBlock({
async sponsorTransactionBlock({
network,
transactionBlock,
client,
...options
client
}) {
const session = await this.getSession();
const keypair = await this.getKeypair();
if (!session || !session.jwt) {
throw new Error("Missing required data for sponsorship.");
}
const transactionBlockKindBytes = await transactionBlock.build({

@@ -235,3 +236,3 @@ onlyTransactionKind: true,

});
const { bytes, signature: sponsorSignature } = await __privateGet(this, _enokiClient).createSponsoredTransactionBlock({
return await __privateGet(this, _enokiClient).createSponsoredTransactionBlock({
jwt: session.jwt,

@@ -241,9 +242,29 @@ network,

});
}
async executeTransactionBlock({
bytes,
digest,
client
}) {
const keypair = await this.getKeypair();
const userSignature = await keypair.signTransactionBlock(fromB64(bytes));
return client.executeTransactionBlock({
transactionBlock: bytes,
signature: [userSignature.signature, sponsorSignature],
...options
await __privateGet(this, _enokiClient).executeSponsoredTransactionBlock({
digest,
signature: userSignature.signature
});
await client.waitForTransactionBlock({ digest });
return { digest };
}
async sponsorAndExecuteTransactionBlock({
network,
transactionBlock,
client
}) {
const { bytes, digest } = await this.sponsorTransactionBlock({
network,
transactionBlock,
client
});
return await this.executeTransactionBlock({ bytes, digest, client });
}
}

@@ -250,0 +271,0 @@ _storageKeys = new WeakMap();

{
"name": "@mysten/enoki",
"version": "0.0.0-experimental-20231129041929",
"version": "0.0.0-experimental-20231130015447",
"description": "TODO: Description",

@@ -50,4 +50,4 @@ "license": "Apache-2.0",

"nanostores": "^0.9.3",
"@mysten/sui.js": "0.0.0-experimental-20231129041929",
"@mysten/zklogin": "0.0.0-experimental-20231129041929"
"@mysten/sui.js": "0.0.0-experimental-20231130015447",
"@mysten/zklogin": "0.0.0-experimental-20231130015447"
},

@@ -54,0 +54,0 @@ "peerDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc