![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@sora-test/wallet-connect
Advanced tools
Provides an interfaces around the injected globals for ease of access by dapp developers.
This library aim to connect multiple extension wallets of Dotsama ecosystem that use the @polkadot/extension-dapp
package with web3Enable. You can use this with any webUI to get features of extension.
We built this packages with idea and some code from @talisman-connect/wallets.
Here is main concept of this package:
wallet.ts
public some useful method will help to start connect with wallets.
You can enable all supported wallets that activated on your browser with this code. Authentication popup of support and activated extension will be showed after this code first time.
// examples/example1.ts
import { getWallets } from '../wallets';
import { Wallet } from '../types';
// Get all supported wallets
const supportedWallets: Wallet[] = getWallets();
// Enable each supported wallet.
supportedWallets.forEach((wallet) => {
if (wallet.installed) {
wallet.enable();
}
});
You can use wallet methods after enable extension. Example get account list:
// examples/example2.ts
import { getWalletBySource } from '../wallets';
import { BaseDotsamaWallet } from '../base-dotsama-wallet';
const wallet = getWalletBySource('subwallet-js') as BaseDotsamaWallet;
if (wallet) {
wallet.enable()
.then(() => {
wallet.getAccounts()
.then((accounts) => {
accounts && accounts.forEach((account) => {
console.log(account.name, account.address)
})
}).catch(console.error)
}).catch(console.error);
}
You also can use object signer with smart contract call
const contract = await new ContractPromise(api, abi, address);
const address = '...' // Account address
const wallet = getWalletBySource('subwallet-js') as BaseDotsamaWallet;
if (wallet) {
await wallet.enable()
const signer = wallet.signer;
if (signer && signer.signRaw && signer.signPayload) {
await contract.tx
.doSomething({ /* Smart contract method input go here */ })
.signAndSend(
address,
{ signer },
async ({ status, dispatchError }) => {
// Handle status callback here
}
);
//Run something after fisish
}
}
You can add more wallet and not required to modify this packages.
To add new wallet you should you can see and example from packages/sub-connect/src/new-wallet-example
packages/sub-connect/src/new-wallet-example/newWalletExample.ts
:
import { addWallet } from '@sora-test/wallet-connect/dotsama/wallets';
import SubWalletLogo from './ExampleWallet.svg';
export const doAddWallet = () => {
addWallet({
extensionName: 'example',
title: 'New Wallet Example',
chromeUrl: 'https://github.com/Koniverse/SubConnect',
mozillaUrl: '',
logo: {
src: SubWalletLogo as string,
alt: 'New Wallet Example'
}
});
};
packages/wallet-connect/src/dotsama/wallets.ts
is called.
// Import codes found here
require('./App.scss');
// Add new example wallet
doAddWallet();
export function App () {
const [walletKey, setWalletKey] = useLocalStorage('wallet-key');
const [currentWallet, setCurrentWallet] = useState<Wallet | undefined>(getWalletBySource(walletKey));
const [isSelectWallet, setIsSelectWallet] = useState(false);
const [accounts, setAccounts] = useState<WalletAccount[]>([]);
// Another code found here
}
Basic functions from wallet.ts:
addWallet(data: WalletInfo): void
: Add your custom wallet to the wallet list. This method need to be call before other method in this file is called.getWallets(): Wallet[]
: Get all supported walletsgetWalletBySource( source: string | unknown )
: Get wallet by extensionNameisWalletInstalled(source: string | unknown)
Check installation, activation of a wallet.Basic functions of wallets (BaseDotsamaWallet):
wallet.intalled
: Check extension is installed and activated or not by checking object window.injectedWeb3
wallet.enable(): Promise<void>
: Enable wallet with your url by authentication popup in the first time and any time before use another wallet functions.wallet.getAccounts(): WalletAccount[]
: Get all account of the wallet.wallet.subscribeAccounts(callback): UnsubscribeFn
: Get and subscribe account changes. This will return self unsubscribe function.wallet.extention
: Return InjectExtension
object that is provided wallet extension. You can found all extension interface in package @polkadot/extension-inject
. We also make quick access of extension with these props:
wallet.signer
: Quick access of wallet.extension.signer
wallet.metadata
: Quick access of wallet.extension.metadata
wallet.provider
: Quick access of wallet.extension.provider
FAQs
Provides an interfaces around the injected globals for ease of access by dapp developers.
The npm package @sora-test/wallet-connect receives a total of 2 weekly downloads. As such, @sora-test/wallet-connect popularity was classified as not popular.
We found that @sora-test/wallet-connect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.