0.0.46 • Published 4 years ago
@abridged/web-wallet-frame-sdk v0.0.46
Abridged Web Wallet Frame Provider
This provider connects dapps into the Abridged web wallet sdk, by using a parent iFrame and a child dapp web3 polyfill.
npm install @abridged/web-wallet-frame-sdk
The parent iFrame should be constructed like:
import { FrameProvider } from "@abridged/web-wallet-frame-sdk";
// SDK - Abridged SDK reference
// window - browser window reference object
// WALLET_PUB_KEY - user's web wallet public key
let wallet = new FrameProvider(sdk, window, WALLET_PUB_KEY);
// Set custom UI transaction prompt
wallet.setPrompt( function(msg, approve, reject) {
var retVal = confirm("Do you want to continue? Transaction: " + msg);
// Approve transaction
if(retVal) approve();
// Reject transaction
else reject();
});
// Allows the dapp to request on/off ramp flow to trigger in the web wallet
// Can optionally be provided erc20 address to onramp directly to token if possible
// Handler is async to allow for waiting on on/off ramp completion
wallet.setRamp( aysnc function(action, token) {
if(action==="buy") {
if(token === null) console.log('wants to buy eth");
else console.log('wants to buy", token);
}
if(action==="sell") {
if(token === null) console.log('wants to sell eth");
else console.log('wants to buy", token);
}
return true; // if successful
});
// The setup function will change the iFrame object src to the target location and start listening for web3 calls from child.
//
// refiFrame - current iFrame reference to iFrame dom object
// frameSrc - url for the IFrame to load once provider is loaded
await wallet.setup(refiFrame, frameSrc);
// Be sure to call this if your React component unloads or redraws
wallet.destroy();
The child iFrame should import the polyfill:
import '@jadbox/iframe-provider-polyfill'
or add via html:
<script src="https://cdn.jsdelivr.net/npm/@jadbox/iframe-provider-polyfill/dist/index.js" type="text/javascript"></script>
0.0.46
4 years ago
0.0.45
4 years ago
0.0.44
4 years ago
0.0.42
4 years ago
0.0.43
4 years ago
0.0.40
4 years ago
0.0.41
4 years ago
0.0.39
4 years ago
0.0.38
4 years ago
0.0.37
4 years ago
0.0.36
4 years ago
0.0.34
4 years ago
0.0.35
4 years ago
0.0.33
4 years ago
0.0.31
4 years ago
0.0.32
4 years ago
0.0.30
4 years ago
0.0.29
4 years ago
0.0.28
4 years ago
0.0.27
4 years ago
0.0.26
4 years ago
0.0.25
4 years ago
0.0.24
4 years ago
0.0.13
4 years ago
0.0.12
4 years ago
0.0.11
4 years ago
0.0.10
4 years ago
0.0.9
4 years ago
0.0.8
4 years ago
0.0.7
4 years ago
0.0.5
4 years ago
0.0.6
4 years ago
0.0.4
4 years ago
0.0.3
4 years ago