@snapshot-labs/snapshot.js 0.4.110 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,8 @@ export declare const domain: {
7
7
  };
8
8
  export default class Client {
9
9
  readonly address: string;
10
- constructor(address?: string);
10
+ readonly options: any;
11
+ constructor(address?: string, options?: {});
11
12
  sign(web3: Web3Provider | Wallet, address: string, message: any, types: any): Promise<unknown>;
12
13
  send(envelop: any): Promise<unknown>;
13
14
  space(web3: Web3Provider | Wallet, address: string, message: Space): Promise<unknown>;
@@ -300,12 +300,14 @@ var domain = {
300
300
  // chainId: 1
301
301
  };
302
302
  var Client = /** @class */ (function () {
303
- function Client(address) {
303
+ function Client(address, options) {
304
304
  if (address === void 0) { address = constants.livenet.sequencer; }
305
+ if (options === void 0) { options = {}; }
305
306
  address = address.replace(constants.livenet.hub, constants.livenet.sequencer);
306
307
  address = address.replace(constants.testnet.hub, constants.testnet.sequencer);
307
308
  address = address.replace(constants.local.hub, constants.local.sequencer);
308
309
  this.address = address;
310
+ this.options = options;
309
311
  }
310
312
  Client.prototype.sign = function (web3, address$1, message, types) {
311
313
  return __awaiter(this, void 0, void 0, function () {
@@ -323,18 +325,18 @@ var Client = /** @class */ (function () {
323
325
  case 1:
324
326
  sig = _a.sent();
325
327
  return [4 /*yield*/, this.send({ address: checksumAddress, sig: sig, data: data })];
326
- case 2:
327
- //console.log('Sign', { address: checksumAddress, sig, data });
328
- return [2 /*return*/, _a.sent()];
328
+ case 2: return [2 /*return*/, _a.sent()];
329
329
  }
330
330
  });
331
331
  });
332
332
  };
333
333
  Client.prototype.send = function (envelop) {
334
334
  return __awaiter(this, void 0, void 0, function () {
335
- var init;
336
- var _this = this;
335
+ var address, init;
337
336
  return __generator(this, function (_a) {
337
+ address = this.address;
338
+ if (envelop.sig === '0x' && this.options.relayerURL)
339
+ address = this.options.relayerURL;
338
340
  init = {
339
341
  method: 'POST',
340
342
  headers: {
@@ -344,7 +346,7 @@ var Client = /** @class */ (function () {
344
346
  body: JSON.stringify(envelop)
345
347
  };
346
348
  return [2 /*return*/, new Promise(function (resolve, reject) {
347
- fetch__default['default'](_this.address, init)
349
+ fetch__default['default'](address, init)
348
350
  .then(function (res) {
349
351
  if (res.ok)
350
352
  return resolve(res.json());
@@ -291,12 +291,14 @@ var domain = {
291
291
  // chainId: 1
292
292
  };
293
293
  var Client = /** @class */ (function () {
294
- function Client(address) {
294
+ function Client(address, options) {
295
295
  if (address === void 0) { address = constants.livenet.sequencer; }
296
+ if (options === void 0) { options = {}; }
296
297
  address = address.replace(constants.livenet.hub, constants.livenet.sequencer);
297
298
  address = address.replace(constants.testnet.hub, constants.testnet.sequencer);
298
299
  address = address.replace(constants.local.hub, constants.local.sequencer);
299
300
  this.address = address;
301
+ this.options = options;
300
302
  }
301
303
  Client.prototype.sign = function (web3, address, message, types) {
302
304
  return __awaiter(this, void 0, void 0, function () {
@@ -314,18 +316,18 @@ var Client = /** @class */ (function () {
314
316
  case 1:
315
317
  sig = _a.sent();
316
318
  return [4 /*yield*/, this.send({ address: checksumAddress, sig: sig, data: data })];
317
- case 2:
318
- //console.log('Sign', { address: checksumAddress, sig, data });
319
- return [2 /*return*/, _a.sent()];
319
+ case 2: return [2 /*return*/, _a.sent()];
320
320
  }
321
321
  });
322
322
  });
323
323
  };
324
324
  Client.prototype.send = function (envelop) {
325
325
  return __awaiter(this, void 0, void 0, function () {
326
- var init;
327
- var _this = this;
326
+ var address, init;
328
327
  return __generator(this, function (_a) {
328
+ address = this.address;
329
+ if (envelop.sig === '0x' && this.options.relayerURL)
330
+ address = this.options.relayerURL;
329
331
  init = {
330
332
  method: 'POST',
331
333
  headers: {
@@ -335,7 +337,7 @@ var Client = /** @class */ (function () {
335
337
  body: JSON.stringify(envelop)
336
338
  };
337
339
  return [2 /*return*/, new Promise(function (resolve, reject) {
338
- fetch(_this.address, init)
340
+ fetch(address, init)
339
341
  .then(function (res) {
340
342
  if (res.ok)
341
343
  return resolve(res.json());