@blocto/sdk
Advanced tools
Comparing version 0.2.11-beta.2 to 0.2.11-beta.3
@@ -50,3 +50,3 @@ /// <reference types="typescript" /> | ||
connect(): Promise<void>; | ||
disconnect(): void; | ||
disconnect(): Promise<void> ; | ||
request(params: { method: string }): Promise<any>; | ||
@@ -53,0 +53,0 @@ |
{ | ||
"name": "@blocto/sdk", | ||
"version": "0.2.11-beta.2", | ||
"version": "0.2.11-beta.3", | ||
"author": "Yang Lin", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -20,3 +20,2 @@ import invariant from 'invariant'; | ||
} | ||
export default class SolanaProvider extends BloctoProvider implements SolanaProviderInterface { | ||
@@ -43,7 +42,2 @@ code: string | null = null; | ||
async request(payload: SolanaRequest) { | ||
const existedSDK = (window as any).solana; | ||
if (existedSDK && existedSDK.isBlocto && payload.method !== 'getAccounts') { | ||
return existedSDK.request(payload); | ||
} | ||
if (!this.connected) { | ||
@@ -60,2 +54,5 @@ await this.connect(); | ||
break; | ||
case 'disconnect': | ||
this.disconnect(); | ||
break; | ||
case 'getAccounts': | ||
@@ -90,6 +87,9 @@ result = this.accounts.length ? this.accounts : await this.fetchAccounts(); | ||
if (existedSDK && existedSDK.isBlocto) { | ||
existedSDK.once('connect', (pubkey: PublicKey) => { | ||
this.accounts = [pubkey.toString()]; | ||
return new Promise((resolve) => { | ||
existedSDK.once('connect', (pubkey: PublicKey) => { | ||
this.accounts = [pubkey.toBase58()]; | ||
resolve(); | ||
}); | ||
existedSDK.connect(); | ||
}); | ||
await existedSDK.connect(); | ||
} | ||
@@ -129,3 +129,8 @@ return new Promise((resolve: () => void, reject) => { | ||
disconnect(): void { | ||
async disconnect(): Promise<void> { | ||
const existedSDK = (window as any).solana; | ||
if (existedSDK && existedSDK.isBlocto) { | ||
await existedSDK.dicconnect(); | ||
return; | ||
} | ||
this.code = null; | ||
@@ -156,2 +161,6 @@ this.accounts = []; | ||
async convertToProgramWalletTransaction(transaction: Transaction): Promise<Transaction> { | ||
const existedSDK = (window as any).solana; | ||
if (existedSDK && existedSDK.isBlocto) { | ||
return existedSDK.convertToProgramWalletTransaction(transaction); | ||
} | ||
const message = await this.request({ | ||
@@ -168,2 +177,6 @@ method: 'convertToProgramWalletTransaction', | ||
async signAndSendTransaction(transaction: Transaction, connection?: Connection): Promise<string> { | ||
const existedSDK = (window as any).solana; | ||
if (existedSDK && existedSDK.isBlocto) { | ||
return existedSDK.signAndSendTransaction(transaction); | ||
} | ||
const extra: any = {}; | ||
@@ -170,0 +183,0 @@ if (connection) { |
@@ -18,3 +18,3 @@ import { Connection, Transaction } from '@solana/web3.js'; | ||
connect(): Promise<void>; | ||
disconnect(): void; | ||
disconnect(): Promise<void> ; | ||
request(params: { method: string }): Promise<any>; | ||
@@ -21,0 +21,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1232191
28239