@polkadot/util-crypto#base64Encode TypeScript Examples

The following examples show how to use @polkadot/util-crypto#base64Encode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: encodeUrl.test.ts    From parity-bridges-ui with GNU General Public License v3.0 6 votes vote down vote up
describe('createPolkadotJsUrl', () => {
  const jsonU8a = stringToU8a(JSON.stringify(types));
  const compressed = zlibSync(jsonU8a, { level: 9 });
  const encoded = base64Encode(compressed);
  const providerUrl = 'wss://wss.rialto.brucke.link';
  const expectedUrl = `https://polkadot.js.org/apps/?rpc=${encodeURIComponent(providerUrl)}&types=${encodeURIComponent(
    encoded
  )}`;

  describe('Test chain', () => {
    it('should retrieve the expected URL for provided types', async () => {
      const result = createPolkadotJsUrl(types, providerUrl);
      expect(result).toEqual(expectedUrl);
    });
  });
});
Example #2
Source File: urlTypes.ts    From subscan-multisig-react with Apache License 2.0 6 votes vote down vote up
export function encodeUrlTypes(types: Record<string, any>): string {
  const jsonU8a = stringToU8a(JSON.stringify(types));
  const compressed = zlibSync(jsonU8a, { level: 9 });
  const encoded = base64Encode(compressed);

  return `${window.location.origin}${window.location.pathname}?rpc=${encodeURIComponent(
    settings.apiUrl
  )}&types=${encodeURIComponent(encoded)}`;
}
Example #3
Source File: urlTypes.ts    From crust-apps with Apache License 2.0 5 votes vote down vote up
export function encodeUrlTypes (types: Record<string, any>): string {
  const jsonU8a = stringToU8a(JSON.stringify(types));
  const compressed = zlibSync(jsonU8a, { level: 9 });
  const encoded = base64Encode(compressed);

  return `${window.location.origin}${window.location.pathname}?rpc=${encodeURIComponent(settings.apiUrl)}&types=${encodeURIComponent(encoded)}`;
}
Example #4
Source File: createPolkadotJsUrl.ts    From parity-bridges-ui with GNU General Public License v3.0 5 votes vote down vote up
export function createPolkadotJsUrl(types: Record<string, any>, providerUrl: string): string {
  const jsonU8a = stringToU8a(JSON.stringify(types));
  const compressed = zlibSync(jsonU8a, { level: 9 });
  const encoded = base64Encode(compressed);

  return `https://polkadot.js.org/apps/?rpc=${encodeURIComponent(providerUrl)}&types=${encodeURIComponent(encoded)}`;
}