1.7.29 • Published 15 days ago

singularity-client-script v1.7.29

Weekly downloads
-
License
ISC
Repository
github
Last release
15 days ago

Singularity-client-script

Inject the following script in your index.html

(function (w, d, s, o, f, js, fjs) {
    w[o] =
      w[o] ||
      function () {
        (w[o].q = w[o].q || []).push(arguments);
      };
    (js = d.createElement(s)), (fjs = d.getElementsByTagName(s)[0]);
    js.id = o;
    js.src = f;
    js.async = 1;
    fjs.parentNode.insertBefore(js, fjs);
  })(window, document, "script", "Singularity", "https://unpkg.com/singularity-client-script@latest/index.js");
  

There are two ways of communication between client and Singualarity SDK

1. Subscription based

  • walletInfo
  • drawerOpen
  • drawerClose
   const handleWalletInfo = (event) => {
            const walletDetails = event.detail.callback();
            console.log('Wallet details', walletDetails);
          };
   window.SingularityEvent.subscribe('walletInfo', handleWalletInfo);
const handleDrawerOpen = () => {
          console.log('Drawer open');
        };
window.SingularityEvent.subscribe('drawerOpen', handleDrawerOpen);
const handleDrawerClose = () => {
          console.log('Drawer close');
        };
window.SingularityEvent.subscribe('drawerClose', handleDrawerClose);

2. Function based

  • close
  • open
  • getConnectUserInfo
  • transactionFlow
  • requestPersonalSignature
  • requestTypedSignature
  • logout

window.SingularityEvent.close();
window.SingularityEvent.open();
const data = await window.SingularityEvent.getConnectUserInfo();
window.SingularityEvent.logout();
const signature = await window.SingularityEvent.requestPersonalSignature("hello world")
 const domain = {
    name: 'GamePay',
    version: '1',
    chainId: 97,
    verifyingContract: '0xED975dB5192aB41713f0080E7306E08188e53E7f'
  };

  const types = {
    bid: [
      { name: 'bidder', type: 'address' },
      { name: 'collectableId', type: 'uint256' },
      { name: 'amount', type: 'uint256' },
      { name: 'nounce', type: 'uint' }
    ]
  };

  const values = {
    bidder: '0xAa81f641d4b3546F05260F49DEc69Eb0314c47De',
    collectableId: 1,
    amount: 100,
    nounce: 1
  };
  
  const primaryType ="bid";
  
const signature = await window.SingularityEvent.requestTypedSignature(domain, primaryType, types, values)
window.SingularityEvent.collectPayment({name:'INIT_COLLECT_PAYMENT',data:
    {
    "transactionId": "090cda7e-1a1a-4e86-8303-916e56d99269",
    "clientReferenceId": "1005",
    "singularityTransactionStatus": "SINGULARITY_TRANSACTION_INITIATED",
    "clientId": "15de55a2-c0a7-420d-97a7-1d907c61ba71",
    "userId": "816acdff-a636-4bec-af27-66f073305537",
    "primaryWalletDetails": {
        "chainId": "80001",
        "chainCategory": "EVM",
        "walletAddress": "0xa9cfB6D7AdFbf5ff9F5A05a78c546547754D3aF3"
    },
    "clientRequestedAsset": {
        "assetId": "66",
        "chainId": "80001",
        "chainName": "MUMBAI",
        "chainCategory": "EVM",
        "chainIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/chain/mumbai.svg",
        "currencyType": "USDC",
        "currencyIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/currency/usdc.svg"
    },
    "paymentOptions": {
        "crypto": [
            {
                "assetId": "55",
                "chainId": "80001",
                "chainName": "MUMBAI",
                "chainCategory": "EVM",
                "currencyType": "MATIC",
                "chainIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/chain/mumbai.svg",
                "decimal": 18,
                "currencyIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/currency/matic.svg",
                "collectCurrencyAmount": "0.77",
                "collectCurrencyAmountInUSD": "0.654654",
                "collectGasInformation": {
                    "collectGasAmount": "3.1500000315E-5",
                    "collectGasAmountInUSD": "2.6775000267749998E-5",
                    "currencyType": "MATIC",
                    "currencyIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/currency/matic.svg"
                },
                "selected": false,
                "userBalanceDetails": []
            },
            {
                "assetId": "66",
                "chainId": "80001",
                "chainName": "MUMBAI",
                "chainCategory": "EVM",
                "currencyType": "USDC",
                "chainIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/chain/mumbai.svg",
                "decimal": 6,
                "currencyIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/currency/usdc.svg",
                "collectCurrencyAmount": "1.0",
                "collectCurrencyAmountInUSD": "1.0",
                "collectGasInformation": {
                    "collectGasAmount": "3.1500000315E-5",
                    "collectGasAmountInUSD": "2.6781300267812997E-5",
                    "currencyType": "MATIC",
                    "currencyIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/currency/matic.svg"
                },
                "selected": false,
                "userBalanceDetails": [
                    {
                        "userAddress": "0xa9cfB6D7AdFbf5ff9F5A05a78c546547754D3aF3",
                        "userBalance": "1.0E-11",
                        "userBalanceInUSD": "1.0E-11"
                    }
                ]
            }
        ],
        "fiat": {
            "paymentMode": {
               "credit_card": [
            {
                "provider": "wert",
                "collectCurrencyAmountInUSD": 1.89,
                "selected": false,
                "currencyIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/currency/creditcard.svg",
                "data": {
                    "signedData": {
                        "address": "0x2a7ac99a7cE7777dD4598e8eb898862a2440fe51",
                        "commodity": "MATIC:mumbai",
                        "commodity_amount": "2",
                        "pk_id": "key1",
                        "sc_address": "0x43b40335Fe283502Aaf08c810e4772cbd4b8107D",
                        "sc_id": "fc8d6225-fdf8-4cfc-a76f-10fdd84325fd",
                        "sc_input_data": "0x23c08d420000000000000000000000002a7ac99a7ce7777dd4598e8eb898862a2440fe5100000000000000000000000017f547ae02a94a0339c4cfe034102423907c45920000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000033132330000000000000000000000000000000000000000000000000000000000",
                        "signature": "905A959AA6CA1E9F6F5ECE18A94021873CBC44C9559CB4CF0E4183AF275C570B3DB77D0915CF240719FA22B0939E08ED8A9AF4964F3ADB65A5B1A9DBE9B08E0E"
                    },
                    "commodity": "MATIC:mumbai",
                    "partnerId": "01GH9K0D7HF976CMVX233RGV9E"
                }
            }
        ]
            }
        }
    },
    "clientRequestedAssetQuantity": "1",
    "userSelectedAsset": null,
    "userSelectedAssetQuantity": null,
    "singularityTransactionType": "RECEIVE",
    "singularityTransactionSubType": null,
    "singularityTransactionExchangeMode": null,
    "singularityExchangePricesAndBalanceDetailsList": null,
    "status": "SUCCESS",
    "error": null
}
});
1.7.30-sandbox.1

15 days ago

1.7.29

3 months ago

1.7.27-sandbox.8

3 months ago

1.7.27-sandbox.9

3 months ago

1.7.27-sandbox.7

3 months ago

1.7.27-sandbox.6

3 months ago

1.7.27-sandbox.4

3 months ago

1.7.27-sandbox.3

3 months ago

1.7.27-sandbox.5

3 months ago

1.7.27

3 months ago

1.7.28

3 months ago

1.7.27-sandbox.2

3 months ago

1.7.27-sandbox.1

3 months ago

1.7.26

4 months ago

1.7.26-sandbox.1

4 months ago

1.7.25

4 months ago

1.7.15

6 months ago

1.7.16

6 months ago

1.7.17

6 months ago

1.7.18

6 months ago

1.7.19

6 months ago

1.7.20

6 months ago

1.7.21

6 months ago

1.7.22

6 months ago

1.7.23

6 months ago

1.7.24

6 months ago

1.7.10

8 months ago

1.7.11

8 months ago

1.7.12

8 months ago

1.7.13

7 months ago

1.7.14

7 months ago

1.6.9-sandbox.6

11 months ago

1.6.9-sandbox.5

11 months ago

1.6.9-sandbox.4

11 months ago

1.7.2-sandbox.7

10 months ago

1.6.9-sandbox.3

11 months ago

1.7.2-sandbox.6

10 months ago

1.6.9-sandbox.2

11 months ago

1.6.9-sandbox.1

11 months ago

1.7.2-sandbox.8

10 months ago

1.7.8-sandbox.1

8 months ago

1.7.9

8 months ago

1.7.8

8 months ago

1.7.7

8 months ago

1.7.6

9 months ago

1.7.5

9 months ago

1.7.4

9 months ago

1.7.3

10 months ago

1.7.2

10 months ago

1.7.1

11 months ago

1.7.0

11 months ago

1.7.7-sandbox.2

8 months ago

1.7.7-sandbox.1

8 months ago

1.6.9

11 months ago

1.6.8

11 months ago

1.7.2-sandbox.3

10 months ago

1.7.2-sandbox.2

10 months ago

1.7.2-sandbox.5

10 months ago

1.7.2-sandbox.4

10 months ago

1.7.2-sandbox.1

10 months ago

1.2.0

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.6.4

1 year ago

1.2.8

1 year ago

1.6.3

1 year ago

1.2.7

1 year ago

1.0.9

1 year ago

1.6.2

1 year ago

1.2.6

1 year ago

1.0.8

1 year ago

1.6.1

1 year ago

1.2.5

1 year ago

1.0.7

1 year ago

1.6.0

1 year ago

1.2.4

1 year ago

1.0.6

1 year ago

1.2.3

1 year ago

1.4.0

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.5.6

1 year ago

1.2.10

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.5.5

1 year ago

1.5.4

1 year ago

1.5.3

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.3.3

1 year ago

1.5.0

1 year ago

1.3.2

1 year ago

1.1.4

1 year ago

1.3.1

1 year ago

1.1.3

1 year ago

1.3.0

1 year ago

1.1.2

1 year ago

1.1.0-develop.1

1 year ago

1.6.7

1 year ago

1.6.6

1 year ago

1.6.5

1 year ago

1.2.9

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago