@silentswap/vue
v0.0.78
Published
Vue 3 composables for integrating with SilentSwap SDK.
Keywords
Readme
@silentswap/vue
Vue 3 composables for integrating with SilentSwap SDK.
Installation
npm install @silentswap/vue
# or
bun add @silentswap/vue
# or
yarn add @silentswap/vueUsage
getSilentSwapClient
Create and manage a SilentSwap client instance:
import { getSilentSwapClient } from '@silentswap/vue';
const { client } = getSilentSwapClient({
config: {
baseUrl: 'https://api.silentswap.com',
},
});getSilentSwapAuth
Handle authentication utilities:
import { getSilentSwapAuth } from '@silentswap/vue';
const {
createSignInMessage,
createEip712DocForOrder,
createEip712DocForWalletGeneration,
} = getSilentSwapAuth();
// Create a sign-in message
const message = createSignInMessage('0x...', 'nonce123', 'app.silentswap.com');
// Create EIP-712 document for order
const orderDoc = createEip712DocForOrder(quoteResponse);
// Create EIP-712 document for wallet generation
const walletDoc = createEip712DocForWalletGeneration('scope', 'token');getSilentSwapOrders
Manage orders and related operations with reactive state:
import { getSilentSwapOrders } from '@silentswap/vue';
const { client } = getSilentSwapClient({ config: yourConfig });
const {
isLoading,
error,
getNonce,
authenticate,
getQuote,
createOrder,
} = getSilentSwapOrders({ client });
// Get nonce for authentication
const nonce = await getNonce('0x...');
// Authenticate user
const authResult = await authenticate({
address: '0x...',
signature: '0x...',
message: '...',
});
// Get a quote
const quote = await getQuote({
sellToken: '0x...',
buyToken: '0x...',
sellAmount: '1000000000000000000',
});
// Create an order
const order = await createOrder({
quoteId: quote.quoteId,
signature: '0x...',
});API Reference
getSilentSwapClient
Parameters
config: SilentSwapClientConfig- Configuration for the SilentSwap client
Returns
client: SilentSwapClient- The SilentSwap client instance
getSilentSwapAuth
Returns
createSignInMessage(address, nonce, domain?)- Create a sign-in messagecreateEip712DocForOrder(quoteResponse)- Create EIP-712 typed data for ordercreateEip712DocForWalletGeneration(scope, token)- Create EIP-712 typed data for wallet generation
getSilentSwapOrders
Parameters
client: SilentSwapClient- The SilentSwap client instance
Returns
isLoading: boolean- Reactive loading stateerror: Error | null- Reactive error stategetNonce(address)- Get nonce for authenticationauthenticate(auth)- Authenticate usergetQuote(quote)- Get a quotecreateOrder(order)- Create an order
Requirements
- Vue 3.0+
- TypeScript (recommended)
