mirror of
https://github.com/status-im/status-go.git
synced 2025-01-12 15:45:07 +00:00
4c6ca00520
* feat(connector)_: impl `eth_requestAccounts` for browser plugin * feat(connector)_: add impl for `wallet_switchEthereumChain` and `eth_chainId` * feat(connector)_: add impl for `eth_sendTransaction` * feat(connector)_: add a signal and an endpoint for wallet ui side * chore_: refactor connector tests * feat(connector)_: impl `eth_requestAccounts` with signal * chore(connector)_: Add test, covering full transaction flow And polish impl & test for connector endpoints * fix(connector)_: temporary allow all origins for ws connection * chore_: review fixes * fix(connector)_: make user select chain id for dApp * fix(connector)_: add requestID and fine tune endpoints * chore(connector)_: naming fixes and tests improvments
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package signal
|
|
|
|
const (
|
|
EventConnectorSendRequestAccounts = "connector.sendRequestAccounts"
|
|
EventConnectorSendTransaction = "connector.sendTransaction"
|
|
)
|
|
|
|
type ConnectorDApp struct {
|
|
URL string `json:"url"`
|
|
Name string `json:"name"`
|
|
IconURL string `json:"iconUrl"`
|
|
}
|
|
|
|
// ConnectorSendRequestAccountsSignal is triggered when a request for accounts is sent.
|
|
type ConnectorSendRequestAccountsSignal struct {
|
|
ConnectorDApp
|
|
RequestID string `json:"requestId"`
|
|
}
|
|
|
|
// ConnectorSendTransactionSignal is triggered when a transaction is requested to be sent.
|
|
type ConnectorSendTransactionSignal struct {
|
|
ConnectorDApp
|
|
RequestID string `json:"requestId"`
|
|
ChainID uint64 `json:"chainId"`
|
|
TxArgs string `json:"txArgs"`
|
|
}
|
|
|
|
func SendConnectorSendRequestAccounts(dApp ConnectorDApp, requestID string) {
|
|
send(EventConnectorSendRequestAccounts, ConnectorSendRequestAccountsSignal{
|
|
ConnectorDApp: dApp,
|
|
RequestID: requestID,
|
|
})
|
|
}
|
|
|
|
func SendConnectorSendTransaction(dApp ConnectorDApp, chainID uint64, txArgs string, requestID string) {
|
|
send(EventConnectorSendTransaction, ConnectorSendTransactionSignal{
|
|
ConnectorDApp: dApp,
|
|
RequestID: requestID,
|
|
ChainID: chainID,
|
|
TxArgs: txArgs,
|
|
})
|
|
}
|