New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stellar-base

Package Overview
Dependencies
Maintainers
8
Versions
182
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stellar-base - npm Package Compare versions

Comparing version 9.0.0-soroban.1 to 9.0.0-soroban.2

42

lib/contract.js

@@ -7,4 +7,6 @@ "use strict";

exports.Contract = void 0;
var _address = require("./address");
var _operation = require("./operation");
var _xdr = _interopRequireDefault(require("./xdr"));
var _strkey = require("./strkey");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -28,2 +30,4 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

* @param {string} contractId - ID of the contract (ex.
* `CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE`, or as a
* 32-byte hex string
* `000000000000000000000000000000000000000000000000000000000000000001`).

@@ -33,12 +37,22 @@ */

var Contract = /*#__PURE__*/function () {
// TODO: Figure out contract owner/id stuff here. How should we represent that?
function Contract(contractId) {
_classCallCheck(this, Contract);
// TODO: Add methods based on the contractSpec (or do that elsewhere?)
this._id = Buffer.from(contractId, 'hex');
try {
// First, try it as a strkey
this._id = _strkey.StrKey.decodeContract(contractId);
} catch (_) {
// If that fails, try it as a hex string
// TODO: Add methods based on the contractSpec (or do that elsewhere?)
var b = Buffer.from(contractId, 'hex');
if (b.length !== 32) {
throw new Error('Invalid contract ID');
}
this._id = b;
}
}
/**
* Returns Stellar contract ID as a hex string, ex.
* Returns Stellar contract ID as a strkey, or hex string, ex.
* `000000000000000000000000000000000000000000000000000000000000000001`.
* @param {'hex'|'strkey'} format - format of output, defaults to 'strkey'
* @returns {string}

@@ -49,6 +63,24 @@ */

value: function contractId() {
return this._id.toString('hex');
var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'strkey';
switch (format) {
case 'strkey':
return _strkey.StrKey.encodeContract(this._id);
case 'hex':
return this._id.toString('hex');
default:
throw new Error("Invalid format: ".concat(format));
}
}
/**
* Returns the address of this contract as an Address type.
* @returns {Address}
*/
}, {
key: "address",
value: function address() {
return _address.Address.contract(this._id);
}
/**
* Returns an operation that will invoke this contract call.

@@ -55,0 +87,0 @@ *

2

package.json
{
"name": "stellar-base",
"version": "9.0.0-soroban.1",
"version": "9.0.0-soroban.2",
"description": "Low-level support library for the Stellar network.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -30,3 +30,3 @@ // TypeScript Version: 2.9

constructor(contractId: string);
contractId(): string;
contractId(format?: 'hex' | 'strkey'): string;
call(method: string, ...params: xdr.ScVal[]): xdr.Operation<Operation.InvokeHostFunction>;

@@ -33,0 +33,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc