Git Product home page Git Product logo

blocto-solana-web3-provider's Introduction

BloctoSolanaWeb3Provider

How to Identify Blocto Provider

If blocto provider injected properly isBlocto will be true

window.solana.isBlocto

Installation

iOS

CocoaPods

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target 'MyApp' do
  pod 'BloctoSolanaWeb3Provider', '0.1.0', :git => 'https://github.com/portto/blocto-solana-web3-provider'
end

App Implementataion

We have to inject the following code just like Ethereum:

(function() {
  var config = {
    address: "\(address)",
    network: "\(network)"
  };
  const bloctoProvider = new window.BloctoSolana(config);
  window.\(windowProperty) = bloctoProvider;
  window.bloctoProvider = bloctoProvider;
})();

The network is "mainnet-beta" or "devnet".

Request Format

{
  "id": <int>,
  "method": <string>,
  ...
}

Response Format

Please call sendResponse func with json string.

  1. If no id, sendResponse({ "id": 0, "error": "invalidRequest" })
  2. If no method, sendResponse({ "id": id, "error": "invalidRequest" })

Successful Response

{
  "id": <int>,
  ...
}

Error Response

{
  "id": <int>,
  "error": <string>
}

Methods

connect

  • Request
{
  "id": <int>,
  "method": "connect"
}
  • Response
{
  "id": <int>,
  "params": {
    "publicKey": <string>
  }
}
  • Error
  1. If no accounts (not enabled), sendResponse( "id": id, "error": "noAccounts") // app presents wallet enable panel
  2. If user click close/cancel button, sendResponse( "id": id, "error": "cancelled")
  3. other unexpected behavior sendResponse({ "id": id, "error": "internal"})

disconnect

  • Request
{
  "id": <int>
}
  • Response
{
  "id": <int>
}
  • Error no error. please remember send response with id.

convertToProgramWalletTransaction

  • Request
{
  "id": <int>,
  "params": {
    "message": <hex-string>
  }
}
  • Response
{
  "id": <int>,
  "result": <hex-string> // raw-transaction-message
}
  • Error
  1. If no message, sendResponse({ "id": id, "error": "invalidRequest" })
  2. If no network connection, sendResponse({ "id": id, "error": "noNetworkConnection" })
  3. other unexpected behavior sendResponse({ "id": id, "error": "internal" })

signAndSendTransaction

  • Request
{
  "id": <int>,
  "params": {
    "message": <hex-string>,
    "publicKeySignaturePairs": { // In most cases, it should be empty.
      <base-58>: <hex-string> // public key: signature
    },
    "isInvokeWrapped": <bool> // check if calling createTransaction or not.
  }
}
  • Response
{
  "id": <int>,
  "result": <hex-string> // tx hash
}
  • Error
  1. If no message or isInvokeWrapped, sendResponse({ "id": id, "error": "invalidRequest" })
  2. If no network connection, sendResponse({ "id": id, "error": "noNetworkConnection" })
  3. If user click close/cancel button, sendResponse({ "id": id, "error": "cancelled" })
  4. other unexpected behavior sendResponse({ "id": id, "error": "internal" })

registerPushNotification

  • Request
{
  "id": <int>,
  "params": {
    "appId": <uuid>,
  }
}
  • Response
{
  "id": <int>,
  "result": <hex-string> // encrypted jwt token
}
  • Error
  1. If no appId param, sendResponse({ "id": id, "error": "invalidRequest" })
  2. If app id not exists (by checking BE api error), sendResponse({ "id": id, "error": "appIdNotExist" })
  3. If no network connection, sendResponse({ "id": id, "error": "noNetworkConnection" })
  4. If user block this website, sendError(id, "blocked")
  5. If user click close/cancel button or tap background to cancel, sendResponse({ "id": id, "error": "cancelled" })
  6. other unexpected behavior sendResponse({ "id": id, "error": "internal" })

blocto-solana-web3-provider's People

Contributors

scottphc avatar

Stargazers

sunsun avatar Shengchao avatar  avatar 北空 avatar  avatar MacOMNI avatar Tao Xu avatar

Watchers

James Cloos avatar Kartik, Chen avatar Hsuan Lee avatar  avatar clement.l avatar Mave Rick avatar Hao avatar Yun-Xuan Lin avatar Mu-Jing-Tsai avatar Jan Lin avatar  avatar

blocto-solana-web3-provider's Issues

unsuccessful

The attempt was unsuccessful. Can you provide Android IOS demo or link

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.